Skip to main content

SessionLayer

Struct SessionLayer 

Source
pub struct SessionLayer<S, ReqBody, ResBody>
where S: SessionStore, ReqBody: Body + Send + 'static, ResBody: Body + Send + 'static,
{ /* private fields */ }
Expand description

Session 中间件层

用于在 tower 应用中添加 Session 支持。

Implementations§

Source§

impl<S, ReqBody, ResBody> SessionLayer<S, ReqBody, ResBody>
where S: SessionStore, ReqBody: Body + Send + 'static, ResBody: Body + Send + 'static,

Source

pub fn new(store: S, config: SessionConfig) -> Self

创建新的 Session 中间件层

Source

pub fn with_store(store: S) -> Self

使用默认配置创建 Session 中间件层

Trait Implementations§

Source§

impl<S, ReqBody, ResBody> Clone for SessionLayer<S, ReqBody, ResBody>
where S: SessionStore + Clone, ReqBody: Body + Send + 'static + Clone, ResBody: Body + Send + 'static + Clone,

Source§

fn clone(&self) -> SessionLayer<S, ReqBody, ResBody>

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
Source§

impl<S, ReqBody, ResBody> Debug for SessionLayer<S, ReqBody, ResBody>
where S: SessionStore + Debug, ReqBody: Body + Send + 'static + Debug, ResBody: Body + Send + 'static + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<S, T, ReqBody, ResBody> Layer<T> for SessionLayer<S, ReqBody, ResBody>
where S: SessionStore, T: Service<Request<ReqBody>, Response = Response<ResBody>> + Clone + Send + 'static, T::Future: Send, ReqBody: Body + Send + 'static, ResBody: Body + Send + 'static,

Source§

type Service = SessionService<T, S, ReqBody, ResBody>

The wrapped service
Source§

fn layer(&self, inner: T) -> Self::Service

Wrap the given service with the middleware, returning a new service that has been decorated with the middleware.

Auto Trait Implementations§

§

impl<S, ReqBody, ResBody> Freeze for SessionLayer<S, ReqBody, ResBody>
where S: Freeze,

§

impl<S, ReqBody, ResBody> RefUnwindSafe for SessionLayer<S, ReqBody, ResBody>
where S: RefUnwindSafe, ReqBody: RefUnwindSafe, ResBody: RefUnwindSafe,

§

impl<S, ReqBody, ResBody> Send for SessionLayer<S, ReqBody, ResBody>

§

impl<S, ReqBody, ResBody> Sync for SessionLayer<S, ReqBody, ResBody>
where ReqBody: Sync, ResBody: Sync,

§

impl<S, ReqBody, ResBody> Unpin for SessionLayer<S, ReqBody, ResBody>
where S: Unpin, ReqBody: Unpin, ResBody: Unpin,

§

impl<S, ReqBody, ResBody> UnsafeUnpin for SessionLayer<S, ReqBody, ResBody>
where S: UnsafeUnpin,

§

impl<S, ReqBody, ResBody> UnwindSafe for SessionLayer<S, ReqBody, ResBody>
where S: UnwindSafe, ReqBody: UnwindSafe, ResBody: UnwindSafe,

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