App

Struct App 

Source
pub struct App<E> {
Show 13 fields pub task: Vault<VecDeque<Task>>, pub task_tmp: Vault<Vec<Task>>, pub affix: Vault<VecDeque<Affix>>, pub req: Vault<VecDeque<Request>>, pub req_tmp: Vault<Vec<Request>>, pub res: Vault<Vec<Result<Response, MetaResponse>>>, pub entities: Vault<Vec<E>>, pub errs: Vault<Vec<Result<Response, MetaResponse>>>, pub args: ArgApp, pub couple: Vault<HashMap<u64, Couple>>, pub session_storer: Option<Box<dyn for<'a> Fn(Poly, &'a ()) -> &'a str + Send>>, pub session_loader: Option<Box<dyn Fn(&str) -> Poly + Send>>, pub body_modifier: Option<Box<dyn for<'c, 'd> Fn(&'c Body, Option<&'d Body>) -> Body + Send>>, /* private fields */
}
Expand description

An abstraction and collection of data flow

Fields§

§task: Vault<VecDeque<Task>>

a vector of Task, store them into directory if too many in order to lower the memory

§task_tmp: Vault<Vec<Task>>

cached Taskto be used

§affix: Vault<VecDeque<Affix>>

a vector of Affix

§req: Vault<VecDeque<Request>>

a vector of Request

§req_tmp: Vault<Vec<Request>>

cached Requestto be spawned

§res: Vault<Vec<Result<Response, MetaResponse>>>

a vector of Response

§entities: Vault<Vec<E>>

collected entities

§errs: Vault<Vec<Result<Response, MetaResponse>>>

some parse-failed Response for manual inspection

§args: ArgApp

Some argument to control the data flow

§couple: Vault<HashMap<u64, Couple>>

couples of task and affix, serving as a backup when the constructed request executed failed

§session_storer: Option<Box<dyn for<'a> Fn(Poly, &'a ()) -> &'a str + Send>>

periodically called to backup Poly NOTE that if None all Poly lost at runtime when interupts happens

§session_loader: Option<Box<dyn Fn(&str) -> Poly + Send>>

called to load Poly at resuming session or load Task to execute NOTE that if None App Starts with new session

§body_modifier: Option<Box<dyn for<'c, 'd> Fn(&'c Body, Option<&'d Body>) -> Body + Send>>

modify the body of Task, Affix in Couple return the Request’s Body if not set, just simply concat the two of them

Implementations§

Source§

impl<'a, E> App<E>

Source

pub fn new() -> Self

create an instance of App

Source

pub fn add_actor<A>(&mut self, spd: &dyn Actor<E, A>)
where A: Affixor + Send + 'static,

add an Actor

Source

pub fn session_loader(&mut self, loader: Box<dyn Fn(&str) -> Poly + Send>)

set the Session Loader

Source

pub fn session_storer( &mut self, storer: Box<dyn for<'b> Fn(Poly, &'b ()) -> &'b str + Send>, )

set the Session Storer

Source

pub fn exts_t( &mut self, f: Box<dyn for<'c, 'd> Fn(&'c Extensions, &'d Extensions) -> (Extensions, Extensions) + Send>, )

set the task extension handler when make a couple of Task and Affix

Source

pub fn exts_p( &mut self, f: Box<dyn for<'c, 'd> Fn(&'c Extensions, &'d Extensions) -> (Extensions, Extensions) + Send>, )

set the affix extension handler when make a couple of Task and Affix

Source

pub fn body_modifier( &mut self, f: Box<dyn for<'c, 'd> Fn(&'c Body, Option<&'d Body>) -> Body + Send>, )

modify the body of Task, Affix in Couple return the Request’s Body if not set, just simply concat the two of them get the overview of App

Source

pub async fn parse<'b>(&self, res: Response) -> (Parsed<E>, u64)

specifically, dispose a Response, handle failed or corrupt Response, and return Parsed or ParseError.

Source

pub async fn parse_all<'b>(&mut self, mware: &'b MiddleWare<'b, E>)

parse multiple Response in App, then drive all Parsed into MiddleWare

Source

pub async fn run<'b, C, A>( &'a mut self, spd: &'a mut dyn Actor<E, A>, middleware: &'a MiddleWare<'b, E>, pipeline: &'a PipeLine<'b, E, C>, ) -> Result<(), Box<dyn Error>>
where A: Affixor + Send + 'static,

drive Dyer into running.

Auto Trait Implementations§

§

impl<E> !Freeze for App<E>

§

impl<E> !RefUnwindSafe for App<E>

§

impl<E> Send for App<E>

§

impl<E> !Sync for App<E>

§

impl<E> Unpin for App<E>

§

impl<E> !UnwindSafe for App<E>

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.

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, 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> 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