Struct LinksPacket
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§
§impl LinksPacket
impl LinksPacket
pub fn new(external_references: bool) -> LinksPacket
pub fn new(external_references: bool) -> LinksPacket
An empty packet.
pub fn pack(
external_references: bool,
links: &[(u64, Vec<Reference>)],
packed_widths: bool,
) -> Result<LinksPacket, BinaryError>
pub fn pack( external_references: bool, links: &[(u64, Vec<Reference>)], packed_widths: bool, ) -> Result<LinksPacket, BinaryError>
Lays out links — (address, references) in ascending address
order — using the version 1 section planner.
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.
pub 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.
pub fn link_count(&self) -> u64
pub fn link_count(&self) -> u64
The number of links in the packet.
pub fn to_bytes(&self) -> Result<Vec<u8>, BinaryError>
pub fn to_bytes(&self) -> Result<Vec<u8>, BinaryError>
Serializes the packet.
pub fn write_to(&self, writer: &mut dyn Write) -> Result<(), BinaryError>
pub fn write_to(&self, writer: &mut dyn Write) -> Result<(), BinaryError>
Writes the packet to writer.
pub fn from_bytes(
bytes: &[u8],
limits: &DecodeLimits,
) -> Result<LinksPacket, BinaryError>
pub fn from_bytes( bytes: &[u8], limits: &DecodeLimits, ) -> Result<LinksPacket, BinaryError>
Parses a complete packet; trailing bytes are an error.
pub fn read_from(
reader: &mut dyn Read,
limits: &DecodeLimits,
) -> Result<Option<LinksPacket>, BinaryError>
pub fn read_from( reader: &mut dyn Read, limits: &DecodeLimits, ) -> Result<Option<LinksPacket>, BinaryError>
Reads one packet from reader; Ok(None) on a clean end of stream.
Trait Implementations§
§impl Clone for LinksPacket
impl Clone for LinksPacket
§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