ProxyHandler

Struct ProxyHandler 

Source
pub struct ProxyHandler<S: HandlerState>(/* private fields */);
Available on crate feature 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,

Source

pub fn new(state: S, instance_pre: ProxyPre<S::StoreData>) -> Self

Create a new ProxyHandler with the specified application state and pre-instance.

Source

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.

Source

pub fn next_req_id(&self) -> u64

Generate a unique request ID.

Source

pub fn state(&self) -> &S

Return a reference to the application state.

Source

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>

Source§

fn clone(&self) -> Self

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

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> GetSetFdFlags for T

Source§

fn get_fd_flags(&self) -> Result<FdFlags, Error>
where T: AsFilelike,

Query the “status” flags for the self file descriptor.
Source§

fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>
where T: AsFilelike,

Create a new SetFdFlags value for use with set_fd_flags. Read more
Source§

fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>
where T: AsFilelike,

Set the “status” flags for the self file descriptor. Read more
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> 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> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T