/// Parses the first word of the segment table.
///
/// The segment table format for streams is defined in the Cap'n Proto
/// [encoding spec](https://capnproto.org/encoding.html#serialization-over-a-stream)
///
/// Returns the segment count and first segment length, or a state if the
/// read would block.
Parses the first word of the segment table.
The segment table format for streams is defined in the Cap'n Proto
[encoding spec]

Returns the segment count and first segment length, or a state if the
read would block.
Parses the first word of the segment table . The segment table format for streams is defined in the Cap ' n Proto [ encoding spec ] Returns the segment count and first segment length or a state if the read would block .
fn parse_segment_table_first(buf: &[u8]) -> Result<(usize, usize)>
{
    let segment_count = u32::from_le_bytes(buf[0..4].try_into().unwrap()).wrapping_add(1);
    if segment_count >= 512 {
        return Err(Error::failed(format!("Too many segments: {}", segment_count)))
    } else if segment_count == 0 {
        return Err(Error::failed(format!("Too few segments: {}", segment_count)))
    }
    let first_segment_len = u32::from_le_bytes(buf[4..8].try_into().unwrap());
    Ok((segment_count as usize, first_segment_len as usize))
}
fn parse_segment_table_first ( buf : & [ u8 ] ) -> Result < ( usize , usize ) > { let segment_count = u32 :: from_le_bytes ( buf [ 0 .. 4 ] . try_into ( ) . unwrap ( ) ) . wrapping_add ( 1 ) ; if segment_count >= 512 { return Err ( Error :: failed ( format ! ( " " segment_count ) ) ) } else if segment_count == 0 { return Err ( Error :: failed ( format ! ( " " segment_count ) ) ) } let first_segment_len = u32 :: from_le_bytes ( buf [ 4 .. 8 ] . try_into ( ) . unwrap ( ) ) ; Ok ( ( segment_count as usize , first_segment_len as usize ) ) }
Parses the first word of the segment table.
Parses the first word of the segment table .
buf
&[u8]