boitalettres/doc/draft.md

46 lines
1.3 KiB
Markdown
Raw Normal View History

2022-05-10 15:42:56 +00:00
# Just Enough Doc
## Run `simple` example
2022-05-10 15:42:56 +00:00
This example is meant to show basic service-based IMAP server with boitalettres library.
- [Source code](../examples/simple.rs)
```shell
2022-05-19 08:18:25 +00:00
$ export RUST_LOG="info,simple=trace,boitalettres=trace"
$ export RUSTFLAGS="--cfg tokio_unstable"
2022-05-10 15:42:56 +00:00
$ cargo run --example simple
```
2022-05-19 08:21:14 +00:00
- Test it manually
Theoretically, IMAP server expected end of lines with `\r\n` but implementations are more liberal.
To check with `\r\n`, use the `socat` command line.
The `nc` command line will send only `\n` when run on Linux, our current implementation supports it.
```
$ socat readline tcp4:127.0.0.1:4567,crnl
$ nc 127.0.0.1 4567
```
2022-05-19 10:45:03 +00:00
If you want to trace this `simple` example with the [`tokio-console`](https://github.com/tokio-rs/console/tree/main/tokio-console) utility, run:
```shell
$ RUSTFLAGS="tokio_unstable" cargo run --example simple --features "tokio/tracing"
```
2022-05-19 08:21:14 +00:00
2022-05-10 15:42:56 +00:00
- [Basic python testing script](../scripts/test_imap.py)
```shell
$ python scripts/test_imap.py
```
## Notes
- The library use the `tracing` library for logging, a basic setup is shown in the `simple` example with the `tracing-subscriber` crate.
2022-05-10 15:42:56 +00:00
## References
- [`imap-codec`](https://docs.rs/imap-codec): IMAP protocol model+encoder/decoder
- [`tower`](https://docs.rs/tower): Service-based request handling library