pub fn read_value_start<R: io::Read + io::Seek>(rd: &mut R, ptr: ValuePtr, size_needed: Option<usize>)
    -> Result<(ValuePrefix, Vec<u8>), HashStoreError>
{
    // use either passed `size_needed` or estimate from ptr
    let prefix_size = mem::size_of::<ValuePrefix>();
    let read_size = prefix_size + size_needed.unwrap_or(ptr_size_est(ptr));

    rd.seek(io::SeekFrom::Start(ptr_file_pos(ptr) - prefix_size as u64))?;
    let mut buffer = vec![0u8; read_size];

    if let Err(e) = rd.read_exact(&mut buffer) {
        // EOF can happen as the size from datapos can be bigger
        // than the actual size; this is solved in read_value_end
        if e.kind() != io::ErrorKind::UnexpectedEof {

            return Err(HashStoreError::IoError(e));
        }
    }
    // split buffer in prefix and content
    let prefix  = bincode::deserialize(&buffer[0..mem::size_of::<ValuePrefix>()])?;
    let content = &buffer[mem::size_of::<ValuePrefix>()..];
    Ok((prefix, content.to_vec()))
}
// Read the prefix from the specified location, and (part of the) value
// The value may not be read in full if the size estimate is incorrect
// in which case read_value_full must be called afterwards if the value is needed
Read the prefix from the specified location, and (part of the) value
The value may not be read in full if the size estimate is incorrect
in which case read_value_full must be called afterwards if the value is needed
Read the prefix from the specified location and ( part of the ) value The value may not be read in full if the size estimate is incorrect in which case read_value_full must be called afterwards if the value is needed
pub fn read_value_start<R: io::Read + io::Seek>(rd: &mut R, ptr: ValuePtr, size_needed: Option<usize>)
    -> Result<(ValuePrefix, Vec<u8>), HashStoreError>
{
    // use either passed `size_needed` or estimate from ptr
    let prefix_size = mem::size_of::<ValuePrefix>();
    let read_size = prefix_size + size_needed.unwrap_or(ptr_size_est(ptr));
    rd.seek(io::SeekFrom::Start(ptr_file_pos(ptr) - prefix_size as u64))?;
    let mut buffer = vec![0u8; read_size];
    if let Err(e) = rd.read_exact(&mut buffer) {
        // EOF can happen as the size from datapos can be bigger
        // than the actual size; this is solved in read_value_end
        if e.kind() != io::ErrorKind::UnexpectedEof {
            return Err(HashStoreError::IoError(e));
        }
    }
    // split buffer in prefix and content
    let prefix  = bincode::deserialize(&buffer[0..mem::size_of::<ValuePrefix>()])?;
    let content = &buffer[mem::size_of::<ValuePrefix>()..];
    Ok((prefix, content.to_vec()))
}
pub fn read_value_start < R : io :: Read + io :: Seek > ( rd : & mut R , ptr : ValuePtr , size_needed : Option < usize > ) -> Result < ( ValuePrefix , Vec < u8 > ) , HashStoreError > { // use either passed `size_needed` or estimate from ptr let prefix_size = mem :: size_of :: < ValuePrefix > ( ) ; let read_size = prefix_size + size_needed . unwrap_or ( ptr_size_est ( ptr ) ) ; rd . seek ( io :: SeekFrom :: Start ( ptr_file_pos ( ptr ) - prefix_size as u64 ) ) ? ; let mut buffer = vec ! [ 0u8 read_size ] ; if let Err ( e ) = rd . read_exact ( & mut buffer ) { // EOF can happen as the size from datapos can be bigger // than the actual size; this is solved in read_value_end if e . kind ( ) != io :: ErrorKind :: UnexpectedEof { return Err ( HashStoreError :: IoError ( e ) ) ; } } // split buffer in prefix and content let prefix = bincode :: deserialize ( & buffer [ 0 .. mem :: size_of :: < ValuePrefix > ( ) ] ) ? ; let content = & buffer [ mem :: size_of :: < ValuePrefix > ( ) .. ] ; Ok ( ( prefix , content . to_vec ( ) ) ) }
Read the prefix from the specified location, and (part of the) value
The value may not be read in full if the size estimate is incorrect
in which case read_value_full must be called afterwards if the value is needed
Read the prefix from the specified location and ( part of the ) value The value may not be read in full if the size estimate is incorrect in which case read_value_full must be called afterwards if the value is needed
rd
&mut R
ptr
ValuePtr
size_needed
Option<usize>
rd
&mut R
ptr
ValuePtr
size_needed
Option<usize>