pub fn parse_cache(contents: Vec<u8>, last_index_update: &str) -> CargoResult<Summaries> {
        let cache = SummariesCache::parse(&contents, last_index_update)?;
        let mut ret = Summaries::default();
        for (version, summary) in cache.versions {
            let (start, end) = subslice_bounds(&contents, summary);
            ret.versions
                .insert(version, MaybeIndexSummary::Unparsed { start, end });
        }
        ret.raw_data = contents;
        return Ok(ret);

        // Returns the start/end offsets of `inner` with `outer`. Asserts that
        // `inner` is a subslice of `outer`.
        fn subslice_bounds(outer: &[u8], inner: &[u8]) -> (usize, usize) {
            let outer_start = outer.as_ptr() as usize;
            let outer_end = outer_start + outer.len();
            let inner_start = inner.as_ptr() as usize;
            let inner_end = inner_start + inner.len();
            assert!(inner_start >= outer_start);
            assert!(inner_end <= outer_end);
            (inner_start - outer_start, inner_end - outer_start)
        }
    }
/// Parses an open `File` which represents information previously cached by
/// Cargo.
Parses an open `File` which represents information previously cached by
Cargo.
Parses an open ` File ` which represents information previously cached by Cargo .
pub fn parse_cache(contents: Vec<u8>, last_index_update: &str) -> CargoResult<Summaries> {
        let cache = SummariesCache::parse(&contents, last_index_update)?;
        let mut ret = Summaries::default();
        for (version, summary) in cache.versions {
            let (start, end) = subslice_bounds(&contents, summary);
            ret.versions
                .insert(version, MaybeIndexSummary::Unparsed { start, end });
        }
        ret.raw_data = contents;
        return Ok(ret);
        // Returns the start/end offsets of `inner` with `outer`. Asserts that
        // `inner` is a subslice of `outer`.
        fn subslice_bounds(outer: &[u8], inner: &[u8]) -> (usize, usize) {
            let outer_start = outer.as_ptr() as usize;
            let outer_end = outer_start + outer.len();
            let inner_start = inner.as_ptr() as usize;
            let inner_end = inner_start + inner.len();
            assert!(inner_start >= outer_start);
            assert!(inner_end <= outer_end);
            (inner_start - outer_start, inner_end - outer_start)
        }
    }
pub fn parse_cache ( contents : Vec < u8 > , last_index_update : & str ) -> CargoResult < Summaries > { let cache = SummariesCache :: parse ( & contents , last_index_update ) ? ; let mut ret = Summaries :: default ( ) ; for ( version , summary ) in cache . versions { let ( start , end ) = subslice_bounds ( & contents , summary ) ; ret . versions . insert ( version , MaybeIndexSummary :: Unparsed { start , end } ) ; } ret . raw_data = contents ; return Ok ( ret ) ; // Returns the start/end offsets of `inner` with `outer`. Asserts that // `inner` is a subslice of `outer`. fn subslice_bounds ( outer : & [ u8 ] , inner : & [ u8 ] ) -> ( usize , usize ) { let outer_start = outer . as_ptr ( ) as usize ; let outer_end = outer_start + outer . len ( ) ; let inner_start = inner . as_ptr ( ) as usize ; let inner_end = inner_start + inner . len ( ) ; assert ! ( inner_start outer_start ) ; assert ! ( inner_end outer_end ) ; ( inner_start - outer_start , inner_end - outer_start ) } }
Parses an open `File` which represents information previously cached by
Cargo.
Parses an open ` File ` which represents information previously cached by Cargo .
contents
Vec<u8>
last_index_update
&str
contents
Vec<u8>
last_index_update
&str