Skip to main content

Crate trillium_smol

Crate trillium_smol 

Source
Expand description

§Trillium adapter using smol and async-global-executor

§Default / 12-factor applications

trillium_smol::run(|conn: trillium::Conn| async move { conn.ok("hello smol") });

§Server configuration

For more details, see trillium_smol::config.

let swansong = trillium_smol::Swansong::new();
trillium_smol::config()
    .with_port(0)
    .with_host("127.0.0.1")
    .without_signals()
    .with_nodelay()
    .with_acceptor(()) // see [`trillium_rustls`] and [`trillium_native_tls`]
    .with_swansong(swansong)
    .run(|conn: trillium::Conn| async move { conn.ok("hello smol") });

§Client

trillium_testing::with_server("ok", |url| async move {
    use trillium_client::{Client, Conn};
    use trillium_smol::TcpConnector;
    let mut conn = Conn::<TcpConnector>::get(url.clone()).execute().await?;
    assert_eq!(conn.response_body().read_string().await?, "ok");

    let client = Client::<TcpConnector>::new();
    let mut conn = client.get(url);
    conn.send().await?;
    assert_eq!(conn.response_body().read_string().await?, "ok");
    Ok(())
});

Re-exports§

pub use async_global_executor;
pub use async_io;
pub use async_net;

Structs§

ClientConfig
configuration for the tcp Connector
Runtime
A type-erased RuntimeTrait implementation. Think of this as an Arc<dyn RuntimeTrait>
SmolRuntime
Runtime for Smol
SmolTransport
A transport newtype for smol
SmolUdpSocket
Async-io-backed UDP socket for use with QUIC transports.
Swansong
🦢 Shutdown manager

Enums§

Binding
A wrapper enum that has blanket implementations for common traits like TryFrom, Stream, AsyncRead, and AsyncWrite. This can contain listeners (like TcpListener), Streams (like Incoming), or bytestreams (like TcpStream).

Traits§

Connector
Interface for runtime and tls adapters for the trillium client
RuntimeTrait
A trait that covers async runtime behavior.

Functions§

config
Configures a server before running it
run
Runs a trillium handler in a sync context with default config
run_async
Runs a trillium handler in an async context with default config