Struct axum_starter::ServerPrepare

source ·
pub struct ServerPrepare<C, Effect, Log = LogInit, State = StateNotReady, Graceful = NoGraceful, Decorator = EmptyDecorator> { /* private fields */ }
Expand description

type for prepare starting

Implementations§

source§

impl<C: 'static, Log, State, Graceful, R: 'static, L: 'static, Decorator> ServerPrepare<C, Result<EffectContainer<R, L>, PrepareError>, Log, State, Graceful, Decorator>
where Decorator: PrepareDecorator,

source

pub fn layer<M: 'static>( self, middleware: M ) -> ServerPrepare<C, Result<EffectContainer<R, Stack<M, L>>, PrepareError>, Log, State, Graceful, Decorator>

adding middleware without previously Prepare action

source§

impl<C: 'static, Log, State, Graceful, Ri: 'static, Li: 'static, Decorator> ServerPrepare<C, Result<EffectContainer<Ri, Li>, PrepareError>, Log, State, Graceful, Decorator>
where Decorator: PrepareDecorator,

source

pub fn prepare_concurrent<F>( self, concurrent: F ) -> ServerPrepare<C, Result<EffectContainer<Ri, Li>, PrepareError>, Log, State, Graceful, Decorator>
where F: FnOnce(ConcurrentPrepareSet<'_, C, Decorator>) -> ConcurrentPrepareSet<'_, C, Decorator> + 'static,

adding a set of Prepare executing concurrently

§Note

Prepare set added by different Self::prepare_concurrent will be executed serially

source

pub fn prepare_route<P, S>( self, prepare: P ) -> ServerPrepare<C, Result<EffectContainer<(<P as Prepare<C>>::Effect, Ri), Li>, PrepareError>, Log, State, Graceful, Decorator>
where P: Prepare<C> + 'static, P::Effect: PrepareRouteEffect<S>, Ri: PrepareRouteEffect<S>, S: Clone + Send + 'static + Sync,

adding a Prepare apply effect on Router

§Note

the Prepare task will be executed one by one.

DO NOT block any task for a long time, neither sync nor async

source

pub fn prepare_state<P>( self, prepare: P ) -> ServerPrepare<C, Result<EffectContainer<Ri, Li>, PrepareError>, Log, State, Graceful, Decorator>
where P: Prepare<C> + 'static, P::Effect: PrepareStateEffect,

adding a Prepare adding effect on State

§Note

the Prepare task will be executed one by one.

DO NOT block any task for a long time, neither sync nor async

source

pub fn prepare_middleware<S, P>( self, prepare: P ) -> ServerPrepare<C, Result<EffectContainer<Ri, Stack<<<P as Prepare<C>>::Effect as PrepareMiddlewareEffect<S>>::Middleware, Li>>, PrepareError>, Log, State, Graceful, Decorator>
where S: 'static, P: Prepare<C> + 'static, P::Effect: PrepareMiddlewareEffect<S>,

adding a Prepare apply effect on State and Middleware

§Note

the Prepare task will be executed one by one.

DO NOT block any task for a long time, neither sync nor async

source

pub fn prepare<P>( self, prepare: P ) -> ServerPrepare<C, Result<EffectContainer<Ri, Li>, PrepareError>, Log, State, Graceful, Decorator>
where P: Prepare<C, Effect = ()> + 'static,

adding a Prepare without effect

source§

impl<C, FutEffect, Log, State, Decorator> ServerPrepare<C, FutEffect, Log, State, NoGraceful, Decorator>

source

pub fn graceful_shutdown<Fut>( self, future: Fut ) -> ServerPrepare<C, FutEffect, Log, State, Graceful<Fut>, Decorator>
where Fut: Future<Output = ()>,

set the graceful shutdown signal

source§

impl<C, FutEffect, Log, Graceful, Decorator> ServerPrepare<C, FutEffect, Log, StateNotReady, Graceful, Decorator>

source

pub fn convert_state<S: FromStateCollector>( self ) -> ServerPrepare<C, FutEffect, Log, StateReady<S>, Graceful, Decorator>

convert internal StateCollector to special State

source

pub fn no_state( self ) -> ServerPrepare<C, FutEffect, Log, StateReady<()>, Graceful, Decorator>

convenient function for ServerPrepare::convert_state::<()>

source§

impl<C, Effect, Log, State, Graceful, Decorator> ServerPrepare<C, Effect, Log, State, Graceful, Decorator>

source

pub fn set_decorator<D>( self, decorator: D ) -> ServerPrepare<C, Effect, Log, State, Graceful, D>

Add Decorator apply on every prepare Future

This PrepareDecorator result will affect all following prepares

this will overwrite old PrepareDecorator, combine multiply PrepareDecorator is Not support. Manual writing combining code instead

see also prepare_decorator

source

pub fn prepare_decorator<D, P>( self, prepare: P ) -> ServerPrepare<C, Effect, Log, State, Graceful, D>
where P: Prepare<C, Effect = D, Error = Infallible, Future = Ready<Result<D, Infallible>>>, C: 'static, D: PrepareDecorator,

Add Decorator generated by a Prepare task,

§NOTE

the Prepare task must be a sync task, in another word, the Prepare::Future should to be Ready

This PrepareDecorator result will affect all following prepares

If you using prepare, you can mark the Prepare task as sync.

use axum_starter::prepare;

// using `sync` make macro generate prepare return Ready
#[prepare(sync Decorator)]
fn foo_decorator(foo:i32)->FooDecorator{
    FooDecorator(foo)
}

struct FooDecorator(i32);

If your [Decorator] do not need any information from the C, you’d better using set_decorator

source§

impl<C, Effect, Log, State, Graceful, Decorator> ServerPrepare<C, Effect, Log, StateReady<State>, Graceful, Decorator>

source

pub fn post_prepare<Args, T>(self, post_prepare: T) -> Self
where T: PostPrepare<State, Args> + Send + 'static, State: Send + 'static + Sync, Args: Send + 'static,

execute a task after all prepare task done before service start

the task can be a FnOnce which has the following features

  1. the arg list all impl Arg: From
  2. is an Async Function
  3. the function return ()
§Note

those tasks will run in a spawn tokio task, do not assume the service has been started

source§

impl<C, FutEffect, State, Graceful, Decorator> ServerPrepare<C, FutEffect, NoLog, State, Graceful, Decorator>

source

pub fn init_logger( self ) -> Result<ServerPrepare<C, FutEffect, LogInit, State, Graceful, Decorator>, <C as LoggerInitialization>::Error>

init the (logger) of this ServerPrepare ,require C impl LoggerInitialization

source§

impl<C: 'static> ServerPrepare<C, Result<EffectContainer<(), Identity>, PrepareError>, NoLog, StateNotReady, NoGraceful, EmptyDecorator>

source

pub fn with_config(config: C) -> Self

prepare staring the service with config

source§

impl<C: 'static, Log, State, Graceful, R, L, Decorator> ServerPrepare<C, Result<EffectContainer<R, L>, PrepareError>, Log, StateReady<State>, Graceful, Decorator>

source

pub async fn preparing<NewResBody>( self ) -> Result<ServerReady<impl Future<Output = Result<(), Error>>, impl Future<Output = Result<(), Error>>>, PrepareStartError>
where C: BindServe, L: Send + 'static, ServiceBuilder<L>: Layer<Route> + Clone, <ServiceBuilder<L> as Layer<Route>>::Service: Send + Clone + Service<Request<Body>, Response = Response<NewResBody>, Error = Infallible> + 'static, <<ServiceBuilder<L> as Layer<Route>>::Service as Service<Request<Body>>>::Future: Send, NewResBody: Body<Data = Bytes> + Send + 'static, NewResBody::Error: Into<BoxError>, R: PrepareRouteEffect<State>, State: FromStateCollector + Clone + Send + 'static + Sync, Graceful: FetchGraceful,

prepare to start this server

this will consume Self then return ServerReady

Auto Trait Implementations§

§

impl<C, Effect, Log, State, Graceful, Decorator> Freeze for ServerPrepare<C, Effect, Log, State, Graceful, Decorator>
where Graceful: Freeze, State: Freeze,

§

impl<C, Effect, Log = LogInit, State = StateNotReady, Graceful = NoGraceful, Decorator = EmptyDecorator> !RefUnwindSafe for ServerPrepare<C, Effect, Log, State, Graceful, Decorator>

§

impl<C, Effect, Log = LogInit, State = StateNotReady, Graceful = NoGraceful, Decorator = EmptyDecorator> !Send for ServerPrepare<C, Effect, Log, State, Graceful, Decorator>

§

impl<C, Effect, Log = LogInit, State = StateNotReady, Graceful = NoGraceful, Decorator = EmptyDecorator> !Sync for ServerPrepare<C, Effect, Log, State, Graceful, Decorator>

§

impl<C, Effect, Log, State, Graceful, Decorator> Unpin for ServerPrepare<C, Effect, Log, State, Graceful, Decorator>
where Graceful: Unpin, State: Unpin, Log: Unpin,

§

impl<C, Effect, Log = LogInit, State = StateNotReady, Graceful = NoGraceful, Decorator = EmptyDecorator> !UnwindSafe for ServerPrepare<C, Effect, Log, State, Graceful, Decorator>

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

source§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. 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> Pipe for T
where T: ?Sized,

source§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
source§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
source§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
source§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
source§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
source§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
source§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
source§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
source§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
source§

impl<'r, T> Provider<'r, &'r T> for T

source§

fn provide(&'r self) -> &'r T

source§

impl<'r, C> Provider<'r, ()> for C

source§

fn provide(&'r self)

source§

impl<'r, C, T1> Provider<'r, (T1,)> for C
where T1: 'r, C: Provider<'r, T1>,

source§

fn provide(&'r self) -> (T1,)

source§

impl<'r, C, T1, T2> Provider<'r, (T1, T2)> for C
where T1: 'r, C: Provider<'r, T1> + Provider<'r, T2>, T2: 'r,

source§

fn provide(&'r self) -> (T1, T2)

source§

impl<'r, C, T1, T2, T3> Provider<'r, (T1, T2, T3)> for C
where T1: 'r, C: Provider<'r, T1> + Provider<'r, T2> + Provider<'r, T3>, T2: 'r, T3: 'r,

source§

impl<'r, C, T1, T2, T3, T4> Provider<'r, (T1, T2, T3, T4)> for C
where T1: 'r, C: Provider<'r, T1> + Provider<'r, T2> + Provider<'r, T3> + Provider<'r, T4>, T2: 'r, T3: 'r, T4: 'r,

source§

impl<'r, C, T1, T2, T3, T4, T5> Provider<'r, (T1, T2, T3, T4, T5)> for C
where T1: 'r, C: Provider<'r, T1> + Provider<'r, T2> + Provider<'r, T3> + Provider<'r, T4> + Provider<'r, T5>, T2: 'r, T3: 'r, T4: 'r, T5: 'r,

source§

impl<'r, C, T1, T2, T3, T4, T5, T6> Provider<'r, (T1, T2, T3, T4, T5, T6)> for C
where T1: 'r, C: Provider<'r, T1> + Provider<'r, T2> + Provider<'r, T3> + Provider<'r, T4> + Provider<'r, T5> + Provider<'r, T6>, T2: 'r, T3: 'r, T4: 'r, T5: 'r, T6: 'r,

source§

impl<'r, C, T1, T2, T3, T4, T5, T6, T7> Provider<'r, (T1, T2, T3, T4, T5, T6, T7)> for C
where T1: 'r, C: Provider<'r, T1> + Provider<'r, T2> + Provider<'r, T3> + Provider<'r, T4> + Provider<'r, T5> + Provider<'r, T6> + Provider<'r, T7>, T2: 'r, T3: 'r, T4: 'r, T5: 'r, T6: 'r, T7: 'r,

source§

impl<'r, C, T1, T2, T3, T4, T5, T6, T7, T8> Provider<'r, (T1, T2, T3, T4, T5, T6, T7, T8)> for C
where T1: 'r, C: Provider<'r, T1> + Provider<'r, T2> + Provider<'r, T3> + Provider<'r, T4> + Provider<'r, T5> + Provider<'r, T6> + Provider<'r, T7> + Provider<'r, T8>, T2: 'r, T3: 'r, T4: 'r, T5: 'r, T6: 'r, T7: 'r, T8: 'r,

source§

impl<'r, C, T1, T2, T3, T4, T5, T6, T7, T8, T9> Provider<'r, (T1, T2, T3, T4, T5, T6, T7, T8, T9)> for C
where T1: 'r, C: Provider<'r, T1> + Provider<'r, T2> + Provider<'r, T3> + Provider<'r, T4> + Provider<'r, T5> + Provider<'r, T6> + Provider<'r, T7> + Provider<'r, T8> + Provider<'r, T9>, T2: 'r, T3: 'r, T4: 'r, T5: 'r, T6: 'r, T7: 'r, T8: 'r, T9: 'r,

source§

impl<'r, C, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> Provider<'r, (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)> for C
where T1: 'r, C: Provider<'r, T1> + Provider<'r, T2> + Provider<'r, T3> + Provider<'r, T4> + Provider<'r, T5> + Provider<'r, T6> + Provider<'r, T7> + Provider<'r, T8> + Provider<'r, T9> + Provider<'r, T10>, T2: 'r, T3: 'r, T4: 'r, T5: 'r, T6: 'r, T7: 'r, T8: 'r, T9: 'r, T10: 'r,

source§

impl<T> Tap for T

source§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
source§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
source§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
source§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
source§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
source§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
source§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
source§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
source§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
source§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
source§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .tap_borrow() only in debug builds, and is erased in release builds.
source§

fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
source§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Calls .tap_ref() only in debug builds, and is erased in release builds.
source§

fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
source§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
source§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
source§

impl<T> TryConv for T

source§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

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

§

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

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,