Changes to doc + example

This commit is contained in:
Quentin 2022-05-19 10:18:25 +02:00
parent 05b5efc8bf
commit 89ffe98bc0
Signed by: quentin
GPG key ID: E9602264D639FF68
2 changed files with 4 additions and 21 deletions

View file

@ -7,6 +7,8 @@ This example is meant to show basic service-based IMAP server with boitalettres
- [Source code](../examples/simple.rs)
```shell
$ export RUST_LOG="info,simple=trace,boitalettres=trace"
$ export RUSTFLAGS="--cfg tokio_unstable"
$ cargo run --example simple
```

View file

@ -1,6 +1,7 @@
use boitalettres::proto::{Request, Response};
use boitalettres::server::accept::addr::{AddrIncoming, AddrStream};
use boitalettres::server::Server;
use tracing_subscriber;
async fn handle_req(req: Request) -> eyre::Result<Response> {
use imap_codec::types::response::Status;
@ -14,7 +15,7 @@ async fn handle_req(req: Request) -> eyre::Result<Response> {
#[tokio::main]
async fn main() -> eyre::Result<()> {
setup_logging();
tracing_subscriber::fmt::init();
let incoming = AddrIncoming::new("127.0.0.1:4567").await?;
@ -33,23 +34,3 @@ async fn main() -> eyre::Result<()> {
Ok(())
}
// Don't mind this, this is just for debugging.
fn setup_logging() {
use tracing_subscriber::prelude::*;
tracing_subscriber::registry()
.with(console_subscriber::spawn())
.with(
tracing_subscriber::fmt::layer().with_filter(
tracing_subscriber::filter::Targets::new()
.with_default(tracing::Level::DEBUG)
.with_target("boitalettres", tracing::Level::TRACE)
.with_target("simple", tracing::Level::TRACE)
.with_target("tower", tracing::Level::TRACE)
.with_target("tokio_tower", tracing::Level::TRACE)
.with_target("mio", tracing::Level::TRACE),
),
)
.init();
}