Extractor

Trait Extractor 

Source
pub trait Extractor<State> {
    type Error: Into<ExtractorError>;

    // Required method
    fn extract(
        frame: Frame,
        context: &Context<State>,
    ) -> Result<Self, Self::Error>
       where Self: Sized;

    // Provided method
    fn extract_from_frame_and_state(
        frame: Frame,
        context: &Context<State>,
    ) -> Result<Self>
       where Self: Sized,
             Self::Error: Into<ExtractorError> { ... }
}
Expand description

Implement extract to allow for extracting values from an action.

Required Associated Types§

Source

type Error: Into<ExtractorError>

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

Types that can be converted into an extractor error are:

  • String
  • Infallible
  • tower::BoxError

Required Methods§

Source

fn extract(frame: Frame, context: &Context<State>) -> Result<Self, Self::Error>
where Self: Sized,

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

Provided Methods§

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.

Implementations on Foreign Types§

Source§

impl<State> Extractor<State> for ()

Source§

type Error = Infallible

Source§

fn extract(_: Frame, _: &Context<State>) -> Result<Self, Self::Error>

Source§

impl<State> Extractor<State> for String

Source§

type Error = ExtractorError

Source§

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

Implementors§

Source§

impl<State> Extractor<State> for Frame

Source§

impl<State> Extractor<State> for HttpGet

Source§

impl<State> Extractor<State> for HttpMeta

Source§

impl<State> Extractor<State> for HttpPost

Source§

impl<State> Extractor<State> for Message

Source§

impl<State> Extractor<State> for MessageData

Source§

impl<State> Extractor<State> for MessageMeta

Source§

impl<State> Extractor<State> for MessageUri

Source§

impl<State, T> Extractor<State> for Path<T>
where T: DeserializeOwned, State: Debug + Clone + Send + Sync + 'static,

Source§

impl<StateContents> Extractor<StateContents> for State<StateContents>
where StateContents: Clone + Send + Sync,

Source§

impl<T, State> Extractor<State> for MessageJson<T>

Source§

impl<T, State> Extractor<State> for MessageMetaJson<T>