pub struct ProxyHandler<S: HandlerState>(/* private fields */);component-model-async only.Expand description
Represents the state of a web server.
Note that this supports optional instance reuse, enabled when
S::max_instance_reuse_count() returns a number greater than one. See
[Self::push] for details.
Implementations§
Source§impl<S> ProxyHandler<S>where
S: HandlerState,
impl<S> ProxyHandler<S>where
S: HandlerState,
Sourcepub fn new(state: S, instance_pre: ProxyPre<S::StoreData>) -> Self
pub fn new(state: S, instance_pre: ProxyPre<S::StoreData>) -> Self
Create a new ProxyHandler with the specified application state and
pre-instance.
Sourcepub fn spawn(&self, req_id: Option<u64>, task: TaskFn<S::StoreData>)
pub fn spawn(&self, req_id: Option<u64>, task: TaskFn<S::StoreData>)
Push a task to the task queue for this handler.
This will either spawn a new background worker to run the task or deliver it to an already-running worker.
The req_id will be passed to <S as HandlerState>::new_store if a
new worker is started for this task. It is intended to be used as a
“request identifier” corresponding to that task and can be used e.g. to
prefix all logging from the Store with that identifier. Note that a
non-None value only makes sense when <S as HandlerState>::max_instance_reuse_count == 1; otherwise the identifier
will not match subsequent tasks handled by the worker.
Sourcepub fn next_req_id(&self) -> u64
pub fn next_req_id(&self) -> u64
Generate a unique request ID.
Sourcepub fn instance_pre(&self) -> &ProxyPre<S::StoreData>
pub fn instance_pre(&self) -> &ProxyPre<S::StoreData>
Return a reference to the pre-instance.
Trait Implementations§
Source§impl<S: HandlerState> Clone for ProxyHandler<S>
impl<S: HandlerState> Clone for ProxyHandler<S>
Auto Trait Implementations§
impl<S> Freeze for ProxyHandler<S>
impl<S> !RefUnwindSafe for ProxyHandler<S>
impl<S> Send for ProxyHandler<S>
impl<S> Sync for ProxyHandler<S>
impl<S> Unpin for ProxyHandler<S>
impl<S> !UnwindSafe for ProxyHandler<S>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
self file descriptor.§fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more