Skip to main content

Target

Enum Target 

Source
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: Bytes

The frame’s complete wire bytes.

§

Object

One framed object, with its wire bytes.

Fields

§meta: &'a ObjectMeta

The 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: Bytes

The object’s complete wire bytes, framing and payload.

§

Datagram

One datagram.

Fields

§raw: Bytes

The 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.

§is_status: bool

Whether the datagram carries an Object Status.

§

StreamEnd

A stream ending. Carries no bytes.

Fields

§is_control_stream: bool

true selects the control-stream rules for this site, false the data-stream rules; they differ, so the flag is not cosmetic.

Implementations§

Source§

impl Target<'_>

Source

pub(crate) fn site(&self) -> Site

Which published site this unit is at.

Source

fn raw(&self) -> Option<Bytes>

The unit’s wire bytes, or None at a site that has no unit.

Source

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-14AnyDatagramHeader there is DatagramObject, whose decode ends by reading all remaining bytes, so header_len is the whole datagram and splicing would emit header ++ 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.
Source

fn payload_offset(&self, draft: DraftVersion) -> Option<usize>

Where the payload starts, when Self::payload_delimited is true.

Source

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.

Trait Implementations§

Source§

impl<'a> Debug for Target<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> !Freeze for Target<'a>

§

impl<'a> RefUnwindSafe for Target<'a>

§

impl<'a> Send for Target<'a>

§

impl<'a> Sync for Target<'a>

§

impl<'a> Unpin for Target<'a>

§

impl<'a> UnsafeUnpin for Target<'a>

§

impl<'a> UnwindSafe for Target<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more