pub(crate) enum Target<'a> {
Control {
raw: Bytes,
},
Object {
meta: &'a ObjectMeta,
subgroup_id_mode: Option<u8>,
raw: Bytes,
},
Datagram {
raw: Bytes,
header_len: Option<usize>,
is_status: bool,
},
StreamEnd {
is_control_stream: bool,
},
}Expand description
The unit an Action was returned for, with every fact
crate::capability::classify needs to judge it.
An enum rather than a struct of Options so that an under-populated
CapCtx is not expressible: each variant carries exactly the facts its
site’s rules read, and Self::cap_ctx is the only place they are
assembled. That is what makes Support::Conditional unreachable at
execution time for the four fact preconditions — see
admit_conditional.
The two StreamAction sites are deliberately not here: they take
execute_stream, so execute cannot be called at a site whose hook
method returns the other type, and Support::NotAttemptable is
structurally unreachable from both entry points.
Variants§
Control
A whole control-stream frame, with its wire bytes.
Fields
raw: BytesThe frame’s complete wire bytes.
Object
One framed object, with its wire bytes.
Fields
meta: &'a ObjectMetaThe object’s framing, from the framer.
subgroup_id_mode: Option<u8>The stream header’s two subgroup-ID mode bits, on drafts 15-19.
None on 07-14, whose header types carry no such pair. Supplying
it on 15-19 is what separates Refusal::ReservedHeaderMode from
Refusal::WouldRedefineSubgroupId.
raw: BytesThe object’s complete wire bytes, framing and payload.
Datagram
One datagram.
Fields
raw: BytesThe datagram’s complete wire bytes.
header_len: Option<usize>data.len() - cursor.len() after a successful
AnyDatagramHeader::decode, or None when the header did not
decode.
This is the raw offset, not the verdict:
Self::payload_delimited applies draft-14’s and the status
datagram’s exceptions on top of it.
StreamEnd
A stream ending. Carries no bytes.
Implementations§
Source§impl Target<'_>
impl Target<'_>
Sourcefn payload_delimited(&self, draft: DraftVersion) -> Option<bool>
fn payload_delimited(&self, draft: DraftVersion) -> Option<bool>
Whether a payload-preserving splice has a locatable boundary.
At the object site, always: the payload is the trailing field in every layout on all fourteen drafts and both stream kinds.
At the datagram site this is where the three exceptions live, and
they live here rather than at the call site because getting one
wrong is silent. header_len is data.len() - cursor.len(), which
is a real boundary only when the decode both succeeded and left the
payload behind:
- draft-14 —
AnyDatagramHeaderthere isDatagramObject, whosedecodeends by reading all remaining bytes, soheader_lenis the whole datagram and splicing would emitheader ++ old ++ new; - a status datagram — no payload slot exists at all;
header_len: None— the hook fires on an undecodable datagram, and there is nothing to splice after.
Sourcefn payload_offset(&self, draft: DraftVersion) -> Option<usize>
fn payload_offset(&self, draft: DraftVersion) -> Option<usize>
Where the payload starts, when Self::payload_delimited is true.
Sourcefn cap_ctx(&self, draft: DraftVersion, replacement_len: Option<u64>) -> CapCtx
fn cap_ctx(&self, draft: DraftVersion, replacement_len: Option<u64>) -> CapCtx
Assemble the facts crate::capability::classify reads.
replacement_len is the only field that comes from the action
rather than from the unit, which is why it is a parameter.