pub struct Packet(/* private fields */);Expand description
One sealed packet: an ordered list of units, rooted in a predecessor.
Identity is over the whole node — payload and parent links together — so a packet cannot be re-parented without changing its id.
Implementations§
Source§impl Packet
impl Packet
Sourcepub fn following(prior: PacketId, units: Vec<UnitId>) -> Self
pub fn following(prior: PacketId, units: Vec<UnitId>) -> Self
A packet linking prior as its predecessor.
Sourcepub fn prior(&self) -> Option<PacketId>
pub fn prior(&self) -> Option<PacketId>
The single predecessor, when there is exactly one.
v0 mints chains, so a packet has zero parents (genesis) or one.
Sourcepub fn is_genesis(&self) -> bool
pub fn is_genesis(&self) -> bool
Whether this packet starts a chain.
Trait Implementations§
Source§impl ContentAddressable for Packet
impl ContentAddressable for Packet
Source§fn canonical_form(&self) -> Result<Vec<u8>, ContentError>
fn canonical_form(&self) -> Result<Vec<u8>, ContentError>
Source§fn content_id(&self) -> Result<ContentId, ContentError>
fn content_id(&self) -> Result<ContentId, ContentError>
Source§fn verify(&self, expected: &ContentId) -> Result<bool, ContentError>
fn verify(&self, expected: &ContentId) -> Result<bool, ContentError>
expected id. Read moreSource§fn ensure_content_id(&self, expected: &ContentId) -> Result<(), ContentError>
fn ensure_content_id(&self, expected: &ContentId) -> Result<(), ContentError>
Ok(false). Read moreimpl Eq for Packet
impl StructuralPartialEq for Packet
Source§impl TryFrom<MerkleNode<PacketBody>> for Packet
impl TryFrom<MerkleNode<PacketBody>> for Packet
Source§fn try_from(raw: RawPacket) -> Result<Self, Self::Error>
fn try_from(raw: RawPacket) -> Result<Self, Self::Error>
The only way in from foreign bytes.
One rule, because the chain has one shape: at most one parent. Nothing else about a decoded packet is a claim this layer can check — whether the units it names exist, or admit, needs a store, and inventing one here would be v0 growing a storage service to answer a structural question.
§Errors
PacketAdmitError::NotAChain when the node carries two or more parents.