3 releases (breaking)

new 0.3.0 Oct 28, 2024
0.2.0 Jul 23, 2024
0.1.0 Jun 7, 2024

#61 in Email

Download history 126/week @ 2024-07-21 24/week @ 2024-07-28 2/week @ 2024-08-04 31/week @ 2024-08-11 47/week @ 2024-08-18 14/week @ 2024-08-25 8/week @ 2024-09-01 1/week @ 2024-09-08 20/week @ 2024-09-15 22/week @ 2024-09-22 16/week @ 2024-09-29 1/week @ 2024-10-06 7/week @ 2024-10-13 1/week @ 2024-10-20 184/week @ 2024-10-27

194 downloads per month
Used in 3 crates (2 directly)

MIT/Apache

110KB
2K SLoC

main audit Coverage

imap-next

%%{init: {'theme': 'neutral' } }%%
flowchart LR
    imap-types --> imap-codec
    imap-codec --> imap-next
    imap-next -.-> imap-proxy
    imap-next -.-> imap-client
    
    style imap-codec stroke-dasharray: 10 5
    style imap-next stroke-width:4px
    
    click imap-types href "https://github.com/duesee/imap-codec/tree/main/imap-types"
    click imap-codec href "https://github.com/duesee/imap-codec"
    click imap-next href "https://github.com/duesee/imap-next"
    click imap-proxy href "https://github.com/duesee/imap-proxy"
    click imap-client href "https://github.com/soywod/imap-client"

imap-next is a thin sans I/O abstraction over IMAP's distinct protocol flows. These are literal handling, AUTHENTICATE, and IDLE.

The way these protocol flows were defined in IMAP couples networking, parsing, and business logic. imap-next untangles them, providing a minimal interface allowing sending and receiving coherent messages. It's a thin layer paving the ground for higher-level client or server implementations. And it's sans I/O enabling the integration in any existing I/O runtime.

Lower-level Libraries

imap-next uses imap-codec internally for parsing and serialization, and re-exposes imap-types.

Higher-level Libraries

  • imap-proxy is an IMAP proxy that gracefully forwards unsolicited responses, abstracts over literals, and Debug-prints messages.
  • imap-client is a methods-based client library with a client.capability(), client.login(), ... interface.

Usage

use std::error::Error;
use imap_next::{
    client::{Client, Event, Options},
    imap_types::{
        command::{Command, CommandBody},
        core::Tag,
    },
    stream::Stream,
};
use tokio::net::TcpStream;

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
    let mut stream = Stream::insecure(TcpStream::connect("127.0.0.1:1143").await?);
    let mut client = Client::new(Options::default());

    loop {
        match stream.next(&mut client).await? {
            event => {
                println!("{event:?}");

                if matches!(event, Event::GreetingReceived { .. }) {
                    break;
                }
            }
        }
    }

    let handle = client.enqueue_command(Command::new("A1", CommandBody::login("Al¹cE", "pa²²w0rd")?)?);

    loop {
        match stream.next(&mut client).await? {
            event => println!("{event:?}"),
        }
    }
}

License

This crate is dual-licensed under Apache 2.0 and MIT terms.

Thanks

Thanks to the NLnet Foundation for supporting imap-next through their NGI Assure program!

NLnet logo Whitespace NGI Assure logo

Dependencies

~3–14MB
~181K SLoC