Frame

Enum 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 duplicate 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, _: &Context<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: &Context<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 HttpFrameResponse

Source§

fn from(frame: Frame) -> Self

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 From<HttpFrameResponse> for Frame

Source§

fn from(frame: HttpFrameResponse) -> 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 StatelessSystem

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 StatefulSystem<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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

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

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

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> Same for T

Source§

type Output = T

Should always be Self
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

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

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,