pub struct ConfigurationRegistrant { /* private fields */ }Expand description
Hyper server bootstrap: owns the shared Router and the bind address.
Mount controllers and global middlewares, then call ConfigurationRegistrant::serve.
ⓘ
let server = std::sync::Arc::new(ConfigurationRegistrant::new(addr));
server.mount_controller(MyController).await;
let bound = server.serve().await?;Implementations§
Source§impl ConfigurationRegistrant
impl ConfigurationRegistrant
Sourcepub fn new(addr: SocketAddr) -> Self
pub fn new(addr: SocketAddr) -> Self
Creates a bootstrap with a fresh router bound to addr on ConfigurationRegistrant::serve.
Sourcepub async fn mount_controller<C: RouteController + 'static>(
&self,
controller: C,
)
pub async fn mount_controller<C: RouteController + 'static>( &self, controller: C, )
Registers every route of controller on the shared router.
Sourcepub async fn mount_middleware(&self, _mw: Middleware)
pub async fn mount_middleware(&self, _mw: Middleware)
Pushes a middleware that runs for every request before route matching.
Sourcepub async fn serve(self: Arc<Self>) -> Result<SocketAddr>
pub async fn serve(self: Arc<Self>) -> Result<SocketAddr>
Binds the socket, spawns the Hyper accept loop in the background, and returns the bound address. Returns an error if the socket cannot be bound.
Auto Trait Implementations§
impl !RefUnwindSafe for ConfigurationRegistrant
impl !UnwindSafe for ConfigurationRegistrant
impl Freeze for ConfigurationRegistrant
impl Send for ConfigurationRegistrant
impl Sync for ConfigurationRegistrant
impl Unpin for ConfigurationRegistrant
impl UnsafeUnpin for ConfigurationRegistrant
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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> ⓘ
Converts
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> ⓘ
Converts
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