fn decode(buf: &[u8]) -> Result<Row, String> {
        let mut buf = buf;

        let mut version_raw = [0u8; 1];
        buf.read_exact(&mut version_raw[..])
            .map_err(|_| "missing version")?;
        // Only one version supported at the moment. This will get more
        // complicated once we change the format and have to migrate old formats
        // to the current one.
        if version_raw[0] != CURRENT_VERSION {
            return Err("unknown version".into());
        }

        let mut len_raw = [0u8; 8];
        buf.read_exact(&mut len_raw[..])
            .map_err(|_| "missing len")?;
        let len = usize::cast_from(u64::from_le_bytes(len_raw));

        // NB: The read calls modify buf to truncate off what they read, so
        // index 0 now corresponds to the part of the original buf immediately
        // after the encoded len.
        let row_data = buf
            .get(0..len)
            .ok_or_else(|| format!("wanted {} row data bytes but had {}", len, buf.len()))?;

        // SAFETY: This was serialized with Row::encode at the same version.
        let row = unsafe { Row::from_bytes_unchecked(row_data.to_owned()) };
        Ok(row)
    }
/// Decodes a row from the permanent storage format.
///
/// This perfectly round-trips through [Row::encode]. It can read rows
/// encoded by historical versions of Materialize back to v(TODO: Figure out
/// our policy).
//
// TODO: Return a RowRef instead?
Decodes a row from the permanent storage format.
This perfectly round-trips through [Row::encode]. It can read rows
encoded by historical versions of Materialize back to v(TODO: Figure out
our policy).


Decodes a row from the permanent storage format . This perfectly round - trips through [ Row :: encode ] . It can read rows encoded by historical versions of Materialize back to v ( TODO : Figure out our policy ) .
fn decode(buf: &[u8]) -> Result<Row, String> {
        let mut buf = buf;
        let mut version_raw = [0u8; 1];
        buf.read_exact(&mut version_raw[..])
            .map_err(|_| "missing version")?;
        // Only one version supported at the moment. This will get more
        // complicated once we change the format and have to migrate old formats
        // to the current one.
        if version_raw[0] != CURRENT_VERSION {
            return Err("unknown version".into());
        }
        let mut len_raw = [0u8; 8];
        buf.read_exact(&mut len_raw[..])
            .map_err(|_| "missing len")?;
        let len = usize::cast_from(u64::from_le_bytes(len_raw));
        // NB: The read calls modify buf to truncate off what they read, so
        // index 0 now corresponds to the part of the original buf immediately
        // after the encoded len.
        let row_data = buf
            .get(0..len)
            .ok_or_else(|| format!("wanted {} row data bytes but had {}", len, buf.len()))?;
        // SAFETY: This was serialized with Row::encode at the same version.
        let row = unsafe { Row::from_bytes_unchecked(row_data.to_owned()) };
        Ok(row)
    }
fn decode ( buf : & [ u8 ] ) -> Result < Row , String > { let mut buf = buf ; let mut version_raw = [ 0u8 ; 1 ] ; buf . read_exact ( & mut version_raw [ .. ] ) . map_err ( | _ | " " ) ? ; // Only one version supported at the moment. This will get more // complicated once we change the format and have to migrate old formats // to the current one. if version_raw [ 0 ] != CURRENT_VERSION { return Err ( " " . into ( ) ) ; } let mut len_raw = [ 0u8 ; 8 ] ; buf . read_exact ( & mut len_raw [ .. ] ) . map_err ( | _ | " " ) ? ; let len = usize :: cast_from ( u64 :: from_le_bytes ( len_raw ) ) ; // NB: The read calls modify buf to truncate off what they read, so // index 0 now corresponds to the part of the original buf immediately // after the encoded len. let row_data = buf . get ( 0 .. len ) . ok_or_else ( | | format ! ( " " len buf len ( ) ) ) ? ; // SAFETY: This was serialized with Row::encode at the same version. let row = unsafe { Row :: from_bytes_unchecked ( row_data . to_owned ( ) ) } ; Ok ( row ) }
Decodes a row from the permanent storage format.
Decodes a row from the permanent storage format .
buf
&[u8]
buf
&[u8]