pub struct Host {
pub options: AppOptions,
/* private fields */
}Fields§
§options: AppOptionsImplementations§
Source§impl Host
impl Host
pub fn builder() -> HostBuilder
pub fn options(&self) -> &AppOptions
Sourcepub async fn run(&self) -> Result<()>
pub async fn run(&self) -> Result<()>
Start the server on all URLs configured in AppOptions.app.Urls.
Automatically detects http:// and https:// URLs from the array. Starts a plain TCP listener for each http:// URL and a TLS listener for each https:// URL. All listeners run concurrently.
Supports graceful shutdown on Ctrl+C/SIGTERM with 30s connection drain.
§Example
{ "App": { "Urls": ["http://localhost:5000", "https://localhost:5030"] } }Sourcepub async fn run_at(&self, addr: &str) -> Result<()>
pub async fn run_at(&self, addr: &str) -> Result<()>
Start the server at a single explicit address (convenience wrapper).
Sourcepub fn server_handle(&self) -> ServerHandle
pub fn server_handle(&self) -> ServerHandle
Return a ServerHandle that can be used to signal graceful shutdown
from application code (e.g., integration tests, health checks).
ⓘ
let host = Host::builder().build();
let handle = host.server_handle();
tokio::spawn(async move { host.run().await });
// ... later:
handle.shutdown();Sourcepub fn into_server(self) -> Server
pub fn into_server(self) -> Server
Consume the host and return a Server that owns the runtime lifecycle.
The returned Server can be .run().await-ed and provides a
handle for graceful shutdown.
Trait Implementations§
Source§impl IHost for Host
impl IHost for Host
fn run<'life0, 'life1, 'async_trait>(
&'life0 self,
addr: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn stop<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Auto Trait Implementations§
impl !RefUnwindSafe for Host
impl !UnwindSafe for Host
impl Freeze for Host
impl Send for Host
impl Sync for Host
impl Unpin for Host
impl UnsafeUnpin for Host
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
Mutably borrows from an owned value. Read more