Enum intrepid_core::Frame

source ·
pub enum Frame {
    Unit,
    Error(Bytes),
    Anonymous(Bytes),
    Message(MessageFrame),
}
Expand description

A frame that can be processed by an action.

Variants§

§

Unit

A unit frame, with nothing in it.

§

Error(Bytes)

An error frame.

§

Anonymous(Bytes)

An unaddressed chunk of bytes.

§

Message(MessageFrame)

An addressed frame.

Implementations§

source§

impl Frame

source

pub fn new(bytes: impl Into<Bytes>) -> Self

Create a new frame from a given set of bytes.

source

pub fn message( uri: impl AsRef<str>, data: impl Into<Frame>, meta: impl Into<Frame>, ) -> Self

Create a message frame.

source

pub fn len(&self) -> usize

The length of the frame in bytes.

source

pub fn is_empty(&self) -> bool

Check if the frame is empty.

source

pub fn as_bytes(&self) -> &[u8]

Get a reference to the frame as a slice of bytes.

source

pub fn into_bytes(self) -> Bytes

Convert the frame’s body into a vector of bytes.

Trait Implementations§

source§

impl AsRef<[u8]> for Frame

source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Clone for Frame

source§

fn clone(&self) -> Frame

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Frame

source§

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

Formats the value using the given formatter. Read more
source§

impl Default for Frame

source§

fn default() -> Frame

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for Frame

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<State> Extractor<State> for Frame

source§

type Error = Infallible

The error type for this extractor. Anything that can be converted into an extractor error can be used as an error type. Read more
source§

fn extract( frame: Frame, _: &ExtractContext<State>, ) -> Result<Self, <Frame as Extractor<State>>::Error>

Take an frame and a state and return a result containing the extracted value or the frame.
source§

fn extract_from_frame_and_state( frame: Frame, context: &ExtractContext<State>, ) -> Result<Self>
where Self: Sized, Self::Error: Into<ExtractorError>,

Extract a value from a frame and state, returning a result containing the extracted value or an error coerced into a crate::Error.
source§

impl From<()> for Frame

source§

fn from(_: ()) -> Self

Converts to this type from the input type.
source§

impl From<Box<dyn Error + Sync + Send>> for Frame

source§

fn from(error: BoxError) -> Self

Converts to this type from the input type.
source§

impl From<Bytes> for Frame

source§

fn from(bytes: Bytes) -> Self

Converts to this type from the input type.
source§

impl From<Error> for Frame

source§

fn from(error: Error) -> Self

Converts to this type from the input type.
source§

impl From<Frame> for Bytes

source§

fn from(frame: Frame) -> Bytes

Converts to this type from the input type.
source§

impl From<Frame> for String

source§

fn from(value: Frame) -> Self

Converts to this type from the input type.
source§

impl<T> From<Option<T>> for Frame
where T: Into<Frame>,

source§

fn from(option: Option<T>) -> Self

Converts to this type from the input type.
source§

impl<T, E> From<Result<T, E>> for Frame
where T: Into<Frame>, E: Into<Frame>,

source§

fn from(result: Result<T, E>) -> Self

Converts to this type from the input type.
source§

impl From<String> for Frame

source§

fn from(value: String) -> Self

Converts to this type from the input type.
source§

impl<T> From<Vec<T>> for Frame
where T: Into<Frame>,

source§

fn from(value: Vec<T>) -> Self

Converts to this type from the input type.
source§

impl From<Vec<u8>> for Frame

source§

fn from(value: Vec<u8>) -> Self

Converts to this type from the input type.
source§

impl Handler<Frame, ()> for System<Stateless, ()>

source§

type Future = FrameFuture

Action futures must resolve into an Frame of some kind.
source§

fn invoke(&self, frame: impl Into<Frame>, _: ()) -> Self::Future

Invoke the action with a given frame and state, returning the frameual frame that will be produced by the action.
source§

fn context(&self) -> ActionContext<()>

Poll for the action context. This is normally a service, but in some cases, it may be a frame handler or a router.
source§

fn as_into_actionable(&self) -> BoxedAction<State>
where Self: Clone + Send + Sync + 'static, Args: Clone + Send + Sync + 'static, State: Clone + Send + Sync + 'static,

Convert this action into a type erased actionable service.
source§

fn into_stream( self, state: State, ) -> (impl Stream<Item = Result<Frame>>, FrameOutbox)
where Self: Clone + Send + Sync + 'static, Args: Clone + Send + Sync + 'static, State: Clone + Send + Sync + 'static,

Use into_stream to turn the action into a stream and a stream handle. See [Actionable::into_stream] for more information.
source§

fn ready(self, state: State) -> ReadyAction<Self, Args, State>
where Self: Clone + Send + 'static, Args: Clone + Send + 'static, State: Clone + Send + 'static,

Use with_state to turn the action into a stateful action, which can be used as a tower::Service.
source§

fn candidate(self) -> CandidateAction<Self, Args, State>
where Self: Clone + Send + 'static, Args: Clone + Send + 'static, State: Clone + Send + 'static,

Create a Candidate actionable from the action, with the given state. Candidates can be “suspended” by boxing them for later.
source§

fn active(self, state: State) -> ActiveAction
where Self: Clone + Send + Sync + 'static, Args: Clone + Send + Sync + 'static, State: Clone + Send + Sync + 'static,

Create an Active actionable from the action, with the given state.
source§

impl<State> Handler<Frame, State> for System<Open, State>
where State: Clone + Send + Sync + 'static,

source§

type Future = FrameFuture

Action futures must resolve into an Frame of some kind.
source§

fn invoke(&self, frame: impl Into<Frame>, state: State) -> Self::Future

Invoke the action with a given frame and state, returning the frameual frame that will be produced by the action.
source§

fn context(&self) -> ActionContext<State>

Poll for the action context. This is normally a service, but in some cases, it may be a frame handler or a router.
source§

fn as_into_actionable(&self) -> BoxedAction<State>
where Self: Clone + Send + Sync + 'static, Args: Clone + Send + Sync + 'static, State: Clone + Send + Sync + 'static,

Convert this action into a type erased actionable service.
source§

fn into_stream( self, state: State, ) -> (impl Stream<Item = Result<Frame>>, FrameOutbox)
where Self: Clone + Send + Sync + 'static, Args: Clone + Send + Sync + 'static, State: Clone + Send + Sync + 'static,

Use into_stream to turn the action into a stream and a stream handle. See [Actionable::into_stream] for more information.
source§

fn ready(self, state: State) -> ReadyAction<Self, Args, State>
where Self: Clone + Send + 'static, Args: Clone + Send + 'static, State: Clone + Send + 'static,

Use with_state to turn the action into a stateful action, which can be used as a tower::Service.
source§

fn candidate(self) -> CandidateAction<Self, Args, State>
where Self: Clone + Send + 'static, Args: Clone + Send + 'static, State: Clone + Send + 'static,

Create a Candidate actionable from the action, with the given state. Candidates can be “suspended” by boxing them for later.
source§

fn active(self, state: State) -> ActiveAction
where Self: Clone + Send + Sync + 'static, Args: Clone + Send + Sync + 'static, State: Clone + Send + Sync + 'static,

Create an Active actionable from the action, with the given state.
source§

impl<State> Handler<Frame, State> for System<Stateful<State>, State>
where State: Clone + Send + Sync + 'static,

source§

type Future = FrameFuture

Action futures must resolve into an Frame of some kind.
source§

fn invoke(&self, frame: impl Into<Frame>, state: State) -> Self::Future

Invoke the action with a given frame and state, returning the frameual frame that will be produced by the action.
source§

fn context(&self) -> ActionContext<State>

Poll for the action context. This is normally a service, but in some cases, it may be a frame handler or a router.
source§

fn as_into_actionable(&self) -> BoxedAction<State>
where Self: Clone + Send + Sync + 'static, Args: Clone + Send + Sync + 'static, State: Clone + Send + Sync + 'static,

Convert this action into a type erased actionable service.
source§

fn into_stream( self, state: State, ) -> (impl Stream<Item = Result<Frame>>, FrameOutbox)
where Self: Clone + Send + Sync + 'static, Args: Clone + Send + Sync + 'static, State: Clone + Send + Sync + 'static,

Use into_stream to turn the action into a stream and a stream handle. See [Actionable::into_stream] for more information.
source§

fn ready(self, state: State) -> ReadyAction<Self, Args, State>
where Self: Clone + Send + 'static, Args: Clone + Send + 'static, State: Clone + Send + 'static,

Use with_state to turn the action into a stateful action, which can be used as a tower::Service.
source§

fn candidate(self) -> CandidateAction<Self, Args, State>
where Self: Clone + Send + 'static, Args: Clone + Send + 'static, State: Clone + Send + 'static,

Create a Candidate actionable from the action, with the given state. Candidates can be “suspended” by boxing them for later.
source§

fn active(self, state: State) -> ActiveAction
where Self: Clone + Send + Sync + 'static, Args: Clone + Send + Sync + 'static, State: Clone + Send + Sync + 'static,

Create an Active actionable from the action, with the given state.
source§

impl PartialEq for Frame

source§

fn eq(&self, other: &Frame) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for Frame

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl StructuralPartialEq for Frame

Auto Trait Implementations§

§

impl !Freeze for Frame

§

impl RefUnwindSafe for Frame

§

impl Send for Frame

§

impl Sync for Frame

§

impl Unpin for Frame

§

impl UnwindSafe for Frame

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> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> DynClone for T
where T: Clone,

source§

fn __clone_box(&self, _: Private) -> *mut ()

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,