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: ArgAppSome 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>
impl<'a, E> App<E>
Sourcepub fn session_loader(&mut self, loader: Box<dyn Fn(&str) -> Poly + Send>)
pub fn session_loader(&mut self, loader: Box<dyn Fn(&str) -> Poly + Send>)
set the Session Loader
Sourcepub fn session_storer(
&mut self,
storer: Box<dyn for<'b> Fn(Poly, &'b ()) -> &'b str + Send>,
)
pub fn session_storer( &mut self, storer: Box<dyn for<'b> Fn(Poly, &'b ()) -> &'b str + Send>, )
set the Session Storer
Sourcepub fn exts_t(
&mut self,
f: Box<dyn for<'c, 'd> Fn(&'c Extensions, &'d Extensions) -> (Extensions, Extensions) + Send>,
)
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
Sourcepub fn exts_p(
&mut self,
f: Box<dyn for<'c, 'd> Fn(&'c Extensions, &'d Extensions) -> (Extensions, Extensions) + Send>,
)
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
Sourcepub fn body_modifier(
&mut self,
f: Box<dyn for<'c, 'd> Fn(&'c Body, Option<&'d Body>) -> Body + Send>,
)
pub fn body_modifier( &mut self, f: Box<dyn for<'c, 'd> Fn(&'c Body, Option<&'d Body>) -> Body + Send>, )
Sourcepub async fn parse<'b>(&self, res: Response) -> (Parsed<E>, u64)
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.
Sourcepub async fn parse_all<'b>(&mut self, mware: &'b MiddleWare<'b, E>)
pub async fn parse_all<'b>(&mut self, mware: &'b MiddleWare<'b, E>)
parse multiple Response in App, then drive all Parsed into MiddleWare