Expand description
The zk2c envelope (core §7.5, 0.72; #976, epic #975): the bytes that carry an owner’s run and sequence number with a sample, before its record, and a call’s forms of the same shape (core 0.92, #980’s C4a).
mutation, a put's payload CH · run · seq · record
delete, a delete's attachment CH · run · seq
event, a put's payload CH · t32 · ms16 · record (core 0.101, #980's C2a)
heartbeat, a put's payload CH · run · seq · body (core 0.81, #978's F1)
owner heartbeat, a put's payload CH · run · seq · body (core 0.108, #1110's H1)
frame, a put's payload CH · run · seq · body (core 0.83, #981's K1)
snapshot, a GET reply's payload CH · run · asof · body (core 0.97, #977's E1)
held stamp, a state GET's payload and its reply's
CH · run · seq (core 0.110, #986's J1)
request, a query's payload CH · record (core 0.92, C4a)
value, a reply's payload CH · run · seq · record (core 0.92, C4a)
error, a reply error's payload CH · run · seq · error (core 0.92, C4a)
CH form (bits 7–5) · run width (bit 4) · tag (bits 3–0)
run 16 or 32 bits unsigned, big-endian, as CH's width bit says
seq 24 bits unsigned, big-endian
record every byte after the seq, read as the resource's type saysAdopted by core §4.3 (0.73, #976’s flip): an owner writes the
envelope on every put of a stream, state, @state or events key
and every delete of a state member, an @stream sample’s excepted. What
a run names and how a seq counts are §4.3’s, and the order of two
in-band stamps crate::seed’s; this module fixes the bytes, a
descriptor’s spelling of a run (Run::hex), and which samples carry
an envelope.
A call’s forms (core 0.92 §7.5, adopted by core 0.94, #985’s C4c,
the only wire of a call since core 0.99’s C4d): a request (Request,
read_query), a value (Envelope::value, read_reply,
read_value) and an error (crate::envelope::ErrorForm,
read_reply_err). A value’s and an error’s stamp is the replying
instance’s as-of mark (§5.1); a request carries none. Each travels under
zenoh/bytes (ENCODING), and under any other Encoding a call’s
sample carries no form.
Parsing reads no contract, as parsing a key does (§1.1): it knows
the sample (SampleKind) and nothing more: a put (Envelope::parse),
a delete (DeleteStamp::parse), or a call’s query, reply or reply
error. So the tag of every form but a delete is reported, never checked
against a type; packed (#979) is the first type kind to define one. A
put carries a mutation, a heartbeat, a frame or a snapshot
(Envelope::form); a heartbeat’s body is read with its covered
revision (crate::heartbeat), its tag that revision’s (an owner
heartbeat is form 6 too, its tag 0 and its body
crate::heartbeat::OwnerHeartbeat::parse’s: the key says which of
the two a put carries, never the bytes), and a frame’s
with its declaration (crate::frame), its tag that declaration’s. A
snapshot’s body (core 0.97, #977’s E1) is taken unread, its asof in the
seq’s place, and read by crate::collection, its tag its
collection’s type’s. An event (core 0.101, #980’s C2a) carries its
time where the stamp would be, and its stamp is its key’s occurrence
chunk (crate::chunk::occurrence): Event, which read_event
and read_put read with the key, key_stamp and time among their
refusals; read without one (Envelope::parse) it is key_stamp. read_put refuses a frame on a key whose kind
token is not stream, and a snapshot on one that is neither state
nor @state (key_kind), which Envelope::parse_on reads. Only a
GET’s reply carries a snapshot, but the parser cannot tell how a put
came, so it reads one either way. An error’s detail is taken unread.
The first refusal that applies is reported, in §7.5’s order, with the
token spec/conformance/envelope/ pins (Refusal::token). Every
envelope and form accepted writes back to its bytes.
A held stamp (core 0.110 §7.5, #986’s J1; adopted by no profile
until desired.v2): a snapshot’s header with no body, form 7 with tag
0, which names one mutation of one state member. A reader sends it on a
state GET (read_get, a fourth sample, SampleKind::Get) and an
owner whose member is unchanged sends it back as that GET’s reply
(read_get_reply, which tells it from a page by its length alone).
Envelope::parse and read_put are unchanged: they cannot tell how
a put came, and read the same bytes as a snapshot’s envelope with no
body. Who sends one and what each concludes is core §4.2’s
(crate::seed::Asked).
Not the error envelope of an earlier core’s call (§5.2 before 0.99), which travelled with no form and which nothing here reads.
Reading (observer §7.3, “the envelope first”): a reader tells a
sample that carries an envelope by its key and its Encoding alone
(carries), reads a put’s payload through read_put and a
delete’s attachment through read_delete, and reads every other
sample as one with no envelope: an @stream sample, a foreign key’s
(§1.7), or one whose owner broke §4.3. The order of two in-band stamps
is crate::seed’s, by the key’s kind (enveloped_kind), and a
sample with no envelope is ordered by its Zenoh timestamp (core §4.2).
Structs§
- Delete
Stamp - A delete’s attachment under the envelope:
CH · run · seq, with tag 0 and no record. It keeps CH, which states the run’s width and lets a reader refuse an attachment that is not an envelope. - Envelope
- 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). - Event
- An event, a put’s payload on an
eventskey (core 0.101 §7.5’s form 4; #980’s C2a):CH · t32 · ms16 · record. Its stamp is its key’s occurrence chunk (crate::chunk::occurrence), CH’s width bit the chunk’s, and it carries the occurrence’s time in the stamp’s place. - Header
- CH, the header byte, read as its three fields. Every byte reads as a header, a reserved form’s included, and writes back to itself.
- Held
Stamp - A held stamp (core 0.110 §7.5; #986’s J1):
CH · run · seq, a snapshot’s header with no body. CH is form 7, the run’s width bit and tag 0:0xe0with a 16-bit run,0xf0with a 32-bit one. It names one mutation of one state member by its in-band stamp; the seq’s place holds the mutation’s seq, never an asof. The same bytes ride a state GET, “I hold this member at (run, seq)”, and that GET’s reply, “its last mutation is (run, seq)”, each underzenoh/bytes(ENCODING). - Request
- A call’s request, a query’s payload:
CH · record(core 0.92 §7.5). CH is a value’s, form 2, with its width bit 0 and its operation’srequesttype’s tag. It carries no run and no seq: its caller need not be an owner. - Seq
- A seq: 24 bits unsigned, written big-endian. A value from 0 to 16,777,215, by construction.
- Stamp
- An envelope’s stamp, the sample’s in-band stamp (core §4.3): its run and its seq, which order a key’s values within one run.
- Tag
- CH’s four low bits: 0 unless the record’s type kind defines a tag. A value from 0 to 15, by construction.
Enums§
- Form
- A form: CH’s three high bits. This version defines all eight: a mutation, a delete, a value, an error, an event (core 0.101), a frame, a heartbeat and a snapshot.
- GetRefusal
- Why a state GET’s payload carries no held stamp (core 0.110 §7.5): its
Encoding(step 2), or the parse’s first refusal (step 3). Either way its owner answers the GET as it answers one with no payload (§4.2): a state GET has no error form. - GetReply
- What a state GET’s reply carries (
read_get_reply). - Reading
- What a put’s payload reads as (
read_put). - Refusal
- Why bytes are not an envelope or a form of their sample. The variants are in §7.5’s order, which is the order they are found in: CH’s checks, the stamp, a delete’s end, then an error’s byte and what follows it.
- Run
- A run: 16 or 32 bits unsigned, written big-endian, as CH’s width bit says. An instance’s ordering epoch (core §4.3): a 16-bit run is a counter in the owner’s record, a 32-bit run a random draw. Two runs of different widths are two runs, whatever their values, and nothing orders two runs.
- Sample
Kind - What carries an envelope or a form, its sample (core §7.5): the parser knows it, and nothing more.
Constants§
- ENCODING
- The Encoding a sample that carries an envelope or a call’s form has (§7.5), as zenoh writes it: its default, with no schema. A raw media type zenoh does not predefine travels as its custom encoding, which zenoh writes as the media type itself (§7.2), so it is never this.
Functions§
- carries
- Whether a sample carries an envelope: its key is a zk2 data key whose
kind is a stream, state or an event (
enveloped_key), and its Encoding iszenoh/bytes(ENCODING). An owner sendszenoh/byteson such a key only with an envelope (core §7.2 asks the predefined Encoding of every other sample, and a raw type keeps its media type), so the test tells the two wires apart. Every other sample is read as one with no envelope (observer §7.3, “Every other sample”). - enveloped_
key - Whether
keyis a zk2 data key whose kind is a stream, state or an event (§1.1, by the grammar alone, with no contract): the keys whose samples may carry an envelope (enveloped_kind). An operation’s (@op) and every control key (@zk) keep their wire. - enveloped_
kind - The kind token of a key whose samples may carry an envelope: a zk2 data
key whose kind is a stream, state or an event, by the grammar alone.
Nonefor an operation’s key, every control key (@zk), a foreign key and a key the grammar refuses. The kind picks how two seqs of one run compare (crate::seed::Order::of_kind). - read_
delete - A delete’s in-band stamp: on a key whose samples may carry an envelope
(
enveloped_key), an attachment that parses as a delete’s envelope. A delete whose attachment is absent or does not parse is read as one with no envelope, by its Zenoh timestamp (core §4.2): an archive’s or a profile’s attachment (telemetry.v1’s Epoch) is never refused here. - read_
event - A put’s payload on
keyread as an event (core 0.101 §7.5’s form 4), or the first refusal that applies, in §7.5’s order: CH’s checks (short,sample_kind,key_kindon a key whose kind token is notevents), thenkey_stamp(the key’s last chunk is no occurrence chunk of CH’s width),short(fewer than 7 bytes) andtime.Nonefor a payload whose CH is not form 4’s, or that has no byte, whichEnvelope::parse_onreads. - read_
get - A state GET’s payload read (core 0.110 §7.5, “A held stamp on a state
GET”), in the text’s three steps: no payload, or one of no byte, carries
no held stamp,
Ok(None), whatever itsEncoding; a payload under anyEncodingbut exactlyzenoh/bytesis refusedencoding, whatever its bytes; any other is parsed (HeldStamp::parse).encodingis the payload’s, as zenoh writes it. - read_
get_ reply - A state GET’s reply payload read (core 0.110 §7.5, “A held stamp on a
reply”): parsed as a put’s payload is, with no key in hand
(
Envelope::parse); a snapshot’s envelope with no byte after its seq is a held stamp, never a page, and its body is not read. The bytes decide which: a page’s body is 10 bytes or more. TheEncodingis not read: a reply under another carries no envelope (carries). - read_
put - A put’s payload read as its key and Encoding say (
carries). - read_
query - A call’s query payload read as a request, or the first refusal that
applies (core 0.92 §7.5). The
Encodingis not read: a form travels underzenoh/bytes(ENCODING), which the caller tells. - read_
reply - A call’s reply payload read as a value, or the first refusal that
applies (core 0.92 §7.5). A GET’s reply that represents a put is a put
(
Envelope::parse), never this. TheEncodingis not read. - read_
reply_ err - A call’s
reply_errpayload read as an error, or the first refusal that applies (core 0.92 §7.5): CH, the stamp, then the error’s byte, its message and its detail, the detail’s bytes unread. TheEncodingis not read:ErrorForm::readgates on it. - read_
value - A call’s reply payload read by its
Encoding(observer §7.3, “A call’s forms first”): underzenoh/bytes(ENCODING, exactly) as the value form (read_reply). A reply refused, by its bytes or by anotherEncoding, is malformed, undecodable and never read as a record with no form, and an answer all the same: it came on the call’s key (core §5.1, “Reading a value”, “Retries”).