fn write_value_block<T: MetricType>(ws: &mut MMVWriterState,
    mut c: &mut Cursor<&mut [u8]>, value: &T,
    metric_blk_off: u64, instance_blk_off: u64) -> io::Result<(usize, usize)> {

    let orig_pos = c.position();

    let value_blk_off =
        ws.value_sec_off
        + ws.value_blk_idx*VALUE_BLOCK_LEN;
    ws.value_blk_idx += 1;
    c.set_position(value_blk_off);

    let (value_offset, value_size);
    if value.type_code() == MTCode::String as u32 {
        // numeric value
        c.write_u64::<Endian>(0)?;

        // string offset

        // we can't pass the actual `m.val()` string to write_mmv_string,
        // and in order to not replicate the logic of write_mmv_string here,
        // we perform an extra write of the string to a temp buffer so we
        // can pass that to write_mmv_string.
        let mut str_buf = [0u8; (STRING_BLOCK_LEN - 1) as usize];
        value.write(&mut (&mut str_buf as &mut [u8]))?;

        let str_val = unsafe { str::from_utf8_unchecked(&str_buf) };
        let string_val_off = write_mmv_string(ws, c, str_val, true)?;
        c.write_u64::<Endian>(string_val_off)?;

        value_offset = string_val_off as usize;
        value_size = STRING_BLOCK_LEN as usize;
    } else {
        value_offset = c.position() as usize;
        value_size = NUMERIC_VALUE_SIZE;

        // numeric value
        value.write(&mut c)?;
        // string offset
        c.write_u64::<Endian>(0)?;
    }
    // offset to metric block
    c.write_u64::<Endian>(metric_blk_off)?;
    // offset to instance block
    c.write_u64::<Endian>(instance_blk_off)?;
    
    c.set_position(orig_pos);
    Ok((value_offset, value_size))
}
// writes `value` at end of value section, updates value count in value TOC,
// and returns the offset `val` was written at and it's size - (offset, size)
//
// leaves the cursor in the original position it was at when passed
writes `value` at end of value section, updates value count in value TOC,
and returns the offset `val` was written at and it's size - (offset, size)

leaves the cursor in the original position it was at when passed
writes ` value ` at end of value section updates value count in value TOC and returns the offset ` val ` was written at and it ' s size - ( offset size ) leaves the cursor in the original position it was at when passed
fn write_value_block<T: MetricType>(ws: &mut MMVWriterState,
    mut c: &mut Cursor<&mut [u8]>, value: &T,
    metric_blk_off: u64, instance_blk_off: u64) -> io::Result<(usize, usize)> {
    let orig_pos = c.position();
    let value_blk_off =
        ws.value_sec_off
        + ws.value_blk_idx*VALUE_BLOCK_LEN;
    ws.value_blk_idx += 1;
    c.set_position(value_blk_off);
    let (value_offset, value_size);
    if value.type_code() == MTCode::String as u32 {
        // numeric value
        c.write_u64::<Endian>(0)?;
        // string offset
        // we can't pass the actual `m.val()` string to write_mmv_string,
        // and in order to not replicate the logic of write_mmv_string here,
        // we perform an extra write of the string to a temp buffer so we
        // can pass that to write_mmv_string.
        let mut str_buf = [0u8; (STRING_BLOCK_LEN - 1) as usize];
        value.write(&mut (&mut str_buf as &mut [u8]))?;
        let str_val = unsafe { str::from_utf8_unchecked(&str_buf) };
        let string_val_off = write_mmv_string(ws, c, str_val, true)?;
        c.write_u64::<Endian>(string_val_off)?;
        value_offset = string_val_off as usize;
        value_size = STRING_BLOCK_LEN as usize;
    } else {
        value_offset = c.position() as usize;
        value_size = NUMERIC_VALUE_SIZE;
        // numeric value
        value.write(&mut c)?;
        // string offset
        c.write_u64::<Endian>(0)?;
    }
    // offset to metric block
    c.write_u64::<Endian>(metric_blk_off)?;
    // offset to instance block
    c.write_u64::<Endian>(instance_blk_off)?;
    c.set_position(orig_pos);
    Ok((value_offset, value_size))
}
fn write_value_block < T : MetricType > ( ws : & mut MMVWriterState , mut c : & mut Cursor < & mut [ u8 ] > , value : & T , metric_blk_off : u64 , instance_blk_off : u64 ) -> io :: Result < ( usize , usize ) > { let orig_pos = c . position ( ) ; let value_blk_off = ws . value_sec_off + ws . value_blk_idx * VALUE_BLOCK_LEN ; ws . value_blk_idx += 1 ; c . set_position ( value_blk_off ) ; let ( value_offset , value_size ) ; if value . type_code ( ) == MTCode :: String as u32 { // numeric value c . write_u64 :: < Endian > ( 0 ) ? ; // string offset // we can't pass the actual `m.val()` string to write_mmv_string, // and in order to not replicate the logic of write_mmv_string here, // we perform an extra write of the string to a temp buffer so we // can pass that to write_mmv_string. let mut str_buf = [ 0u8 ; ( STRING_BLOCK_LEN - 1 ) as usize ] ; value . write ( & mut ( & mut str_buf as & mut [ u8 ] ) ) ? ; let str_val = unsafe { str :: from_utf8_unchecked ( & str_buf ) } ; let string_val_off = write_mmv_string ( ws , c , str_val , true ) ? ; c . write_u64 :: < Endian > ( string_val_off ) ? ; value_offset = string_val_off as usize ; value_size = STRING_BLOCK_LEN as usize ; } else { value_offset = c . position ( ) as usize ; value_size = NUMERIC_VALUE_SIZE ; // numeric value value . write ( & mut c ) ? ; // string offset c . write_u64 :: < Endian > ( 0 ) ? ; } // offset to metric block c . write_u64 :: < Endian > ( metric_blk_off ) ? ; // offset to instance block c . write_u64 :: < Endian > ( instance_blk_off ) ? ; c . set_position ( orig_pos ) ; Ok ( ( value_offset , value_size ) ) }
writes `value` at end of value section, updates value count in value TOC,
and returns the offset `val` was written at and it's size - (offset, size)
writes ` value ` at end of value section updates value count in value TOC and returns the offset ` val ` was written at and it ' s size - ( offset size )
ws
&mut MMVWriterState
c
&mut Cursor<&mut [u8]>
value
&T
metric_blk_off
u64
instance_blk_off
u64