pub struct Envelope<'a> {
pub form: Form,
pub tag: Tag,
pub stamp: Stamp,
pub record: &'a [u8],
}Expand description
A put’s payload under the envelope, or a call’s reply in its value
form. This version defines four forms for a put: the mutation,
CH · run · seq · record, the frame, CH · run · seq · body (core
0.83), the heartbeat, CH · run · seq · body (core 0.81), and the
snapshot, CH · run · asof · body (core 0.97), a GET reply’s. A reply’s
value has a mutation’s shape, CH · run · seq · record (core 0.92).
Fields§
§form: FormForm::Mutation, Form::Frame, Form::Heartbeat or
Form::Snapshot on a put, Form::Value on a reply.
tag: TagA mutation’s: 0 unless the record’s type kind defines a tag. A
frame’s: its declaration’s (crate::frame::Layout::tag). A
heartbeat’s: its covered revision’s, and 0 for an owner
heartbeat, whose groups each carry one. A snapshot’s: its collection’s
type’s. A value’s: its operation’s response type’s, or its
summary type’s on a summary reply.
stamp: StampA value’s is the replying instance’s as-of mark (core §5.1). A snapshot’s is the owner’s run and its asof, in the seq’s place.
record: &'a [u8]Every byte after the seq, possibly none: a mutation’s or a value’s
record, read as the resource’s type says (§7.1), or a frame’s, a
heartbeat’s or a snapshot’s body, a snapshot’s unread
(crate::collection::Page::read reads it).
Implementations§
Source§impl<'a> Envelope<'a>
impl<'a> Envelope<'a>
Sourcepub const fn mutation(tag: Tag, stamp: Stamp, record: &'a [u8]) -> Envelope<'a>
pub const fn mutation(tag: Tag, stamp: Stamp, record: &'a [u8]) -> Envelope<'a>
A mutation: a put’s record under its stamp.
Sourcepub const fn value(tag: Tag, stamp: Stamp, record: &'a [u8]) -> Envelope<'a>
pub const fn value(tag: Tag, stamp: Stamp, record: &'a [u8]) -> Envelope<'a>
A value: a call’s reply, its record under the replying instance’s as-of mark (core 0.92 §5.1, §7.5).
Sourcepub const fn frame(tag: Tag, stamp: Stamp, body: &'a [u8]) -> Envelope<'a>
pub const fn frame(tag: Tag, stamp: Stamp, body: &'a [u8]) -> Envelope<'a>
A frame: a body under the stamp of its record 0 (core §7.7).
Sourcepub const fn snapshot(
tag: Tag,
run: Run,
asof: Seq,
body: &'a [u8],
) -> Envelope<'a>
pub const fn snapshot( tag: Tag, run: Run, asof: Seq, body: &'a [u8], ) -> Envelope<'a>
A snapshot’s page: its body under the owner’s run and its asof, in
the seq’s place (core 0.97 §7.5, crate::collection).
Sourcepub const fn is_frame(&self) -> bool
pub const fn is_frame(&self) -> bool
Whether it is a frame’s: its bytes after the seq are a body, never a record.
Sourcepub const fn is_heartbeat(&self) -> bool
pub const fn is_heartbeat(&self) -> bool
Whether it is a heartbeat’s: its bytes after the seq are a body, never a record.
Sourcepub const fn is_snapshot(&self) -> bool
pub const fn is_snapshot(&self) -> bool
Whether it is a snapshot’s page: its bytes after the asof are a body, never a record.
Sourcepub fn parse(bytes: &'a [u8]) -> Result<Envelope<'a>, Refusal>
pub fn parse(bytes: &'a [u8]) -> Result<Envelope<'a>, Refusal>
A put’s payload read as an envelope, or the first refusal that
applies. The key is not read, so a frame or a snapshot is accepted
on any key: Envelope::parse_on reads its key’s kind.
§Errors
Refusal::Empty, Refusal::Reserved, Refusal::WrongSample
for a form a put does not carry, or Refusal::Short, in that
order.
Sourcepub fn parse_on(
bytes: &'a [u8],
kind: KindToken,
) -> Result<Envelope<'a>, Refusal>
pub fn parse_on( bytes: &'a [u8], kind: KindToken, ) -> Result<Envelope<'a>, Refusal>
Envelope::parse for a put on a key of the kind kind: a frame on
a key whose kind is not stream, or a snapshot on one that is
neither state nor @state, is Refusal::KeyKind, after the
sample’s kind and before the stamp (core §7.5).
§Errors
Envelope::parse’s, and Refusal::KeyKind after
Refusal::WrongSample.
Trait Implementations§
impl<'a> Copy for Envelope<'a>
impl<'a> Eq for Envelope<'a>
impl<'a> StructuralPartialEq for Envelope<'a>
Auto Trait Implementations§
impl<'a> Forget for Envelope<'a>
impl<'a> Freeze for Envelope<'a>
impl<'a> Move for Envelope<'a>
impl<'a> RefUnwindSafe for Envelope<'a>
impl<'a> Send for Envelope<'a>
impl<'a> Sync for Envelope<'a>
impl<'a> Unpin for Envelope<'a>
impl<'a> UnsafeUnpin for Envelope<'a>where
&'a [u8]: UnsafeUnpin,
impl<'a> UnwindSafe for Envelope<'a>where
&'a [u8]: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more