pub struct LinksPacket {
pub external_references: bool,
pub sections: Vec<Section>,
}Expand description
A decoded binary links packet.
Fields§
§external_references: boolHeader bit 0: references may be external (Hybrid encoding).
sections: Vec<Section>The links, section by section.
Implementations§
Source§impl LinksPacket
impl LinksPacket
Sourcepub fn pack(
external_references: bool,
links: &[(u64, Vec<Reference>)],
packed_widths: bool,
) -> ProtocolResult<Self>
pub fn pack( external_references: bool, links: &[(u64, Vec<Reference>)], packed_widths: bool, ) -> ProtocolResult<Self>
Lays out links — (address, references) in ascending address
order — in as few bytes as the format allows.
Holes between addresses start new sections. Without packed_widths
every section uses the width of the widest reference, so all
references have the same size. With it each section gets the
narrowest width its links need and sections split wherever that saves
bytes; the result is never larger than the uniform one.
Sourcepub fn links(&self) -> impl Iterator<Item = (u64, &[Reference])> + '_
pub fn links(&self) -> impl Iterator<Item = (u64, &[Reference])> + '_
Every link with its address, in address order.
Sourcepub fn link_count(&self) -> u64
pub fn link_count(&self) -> u64
The number of links in the packet.
Sourcepub fn to_bytes(&self) -> ProtocolResult<Vec<u8>>
pub fn to_bytes(&self) -> ProtocolResult<Vec<u8>>
Serializes the packet.
Sourcepub fn write_to(&self, writer: &mut dyn Write) -> ProtocolResult<()>
pub fn write_to(&self, writer: &mut dyn Write) -> ProtocolResult<()>
Writes the packet to writer.
Sourcepub fn from_bytes(bytes: &[u8], limits: &DecodeLimits) -> ProtocolResult<Self>
pub fn from_bytes(bytes: &[u8], limits: &DecodeLimits) -> ProtocolResult<Self>
Parses a complete packet; trailing bytes are an error.
Sourcepub fn read_from(
reader: &mut dyn Read,
limits: &DecodeLimits,
) -> ProtocolResult<Option<Self>>
pub fn read_from( reader: &mut dyn Read, limits: &DecodeLimits, ) -> ProtocolResult<Option<Self>>
Reads one packet from reader; Ok(None) on a clean end of stream.
Trait Implementations§
Source§impl Clone for LinksPacket
impl Clone for LinksPacket
Source§fn clone(&self) -> LinksPacket
fn clone(&self) -> LinksPacket
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more