fn write_mmv_string(ws: &mut MMVWriterState,
    c: &mut Cursor<&mut [u8]>, string: &str, is_value: bool) -> io::Result<u64> {

    if string.len() == 0 {
        return Ok(0);
    }

    let orig_pos = c.position();

    let string_block_off =
        ws.string_sec_off
        + STRING_BLOCK_LEN*ws.string_blk_idx;
        
    // only cache if the string is not a value
    if !is_value {
        if let Some(cached_offset) = ws.non_value_string_cache.get(string).clone() {
            if let &Some(off) = cached_offset {
                return Ok(off);
            }
        }

        ws.non_value_string_cache.insert(string.to_owned(), Some(string_block_off));
    }

    // write string in string section
    c.set_position(string_block_off);
    c.write_all(string.as_bytes())?;
    c.write_all(&[0])?;

    ws.string_blk_idx += 1;

    c.set_position(orig_pos);
    Ok(string_block_off)
}
// writes `string` at end of string section, updates string count in string TOC,
// and returns the offset `string` was written at
//
// leaves the cursor in the original position it was at when passed
//
// when writing first string in MMV, also writes the string TOC block
writes `string` at end of string section, updates string count in string TOC,
and returns the offset `string` was written at

leaves the cursor in the original position it was at when passed

when writing first string in MMV, also writes the string TOC block
writes ` string ` at end of string section updates string count in string TOC and returns the offset ` string ` was written at leaves the cursor in the original position it was at when passed when writing first string in MMV also writes the string TOC block
fn write_mmv_string(ws: &mut MMVWriterState,
    c: &mut Cursor<&mut [u8]>, string: &str, is_value: bool) -> io::Result<u64> {
    if string.len() == 0 {
        return Ok(0);
    }
    let orig_pos = c.position();
    let string_block_off =
        ws.string_sec_off
        + STRING_BLOCK_LEN*ws.string_blk_idx;
    // only cache if the string is not a value
    if !is_value {
        if let Some(cached_offset) = ws.non_value_string_cache.get(string).clone() {
            if let &Some(off) = cached_offset {
                return Ok(off);
            }
        }
        ws.non_value_string_cache.insert(string.to_owned(), Some(string_block_off));
    }
    // write string in string section
    c.set_position(string_block_off);
    c.write_all(string.as_bytes())?;
    c.write_all(&[0])?;
    ws.string_blk_idx += 1;
    c.set_position(orig_pos);
    Ok(string_block_off)
}
fn write_mmv_string ( ws : & mut MMVWriterState , c : & mut Cursor < & mut [ u8 ] > , string : & str , is_value : bool ) -> io :: Result < u64 > { if string . len ( ) == 0 { return Ok ( 0 ) ; } let orig_pos = c . position ( ) ; let string_block_off = ws . string_sec_off + STRING_BLOCK_LEN * ws . string_blk_idx ; // only cache if the string is not a value if ! is_value { if let Some ( cached_offset ) = ws . non_value_string_cache . get ( string ) . clone ( ) { if let & Some ( off ) = cached_offset { return Ok ( off ) ; } } ws . non_value_string_cache . insert ( string . to_owned ( ) , Some ( string_block_off ) ) ; } // write string in string section c . set_position ( string_block_off ) ; c . write_all ( string . as_bytes ( ) ) ? ; c . write_all ( & [ 0 ] ) ? ; ws . string_blk_idx += 1 ; c . set_position ( orig_pos ) ; Ok ( string_block_off ) }
writes `string` at end of string section, updates string count in string TOC,
and returns the offset `string` was written at
writes ` string ` at end of string section updates string count in string TOC and returns the offset ` string ` was written at
ws
&mut MMVWriterState
c
&mut Cursor<&mut [u8]>
string
&str
is_value
bool