2 个不稳定版本

0.2.0 2024 年 7 月 23 日
0.1.0 2024 年 6 月 7 日

电子邮件 类别中排名 #70

Download history 137/week @ 2024-06-06 5/week @ 2024-06-13 1/week @ 2024-06-20 87/week @ 2024-07-18 60/week @ 2024-07-25 5/week @ 2024-08-01 9/week @ 2024-08-08 46/week @ 2024-08-15

每月下载量 151
2 crates 中使用

MIT/Apache 许可

105KB
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 是在 IMAP 独特协议流程(如文字处理、AUTHENTICATE 和 IDLE)之上的轻量级无 I/O 抽象。

IMAP 中定义的这些协议流程将网络、解析和业务逻辑耦合在一起。 imap-next 解耦了它们,提供了一个最小接口,允许发送和接收连贯的消息。它是一个薄层,为高级客户端或服务器实现铺平道路。并且它是无 I/O 的,使得它可以集成到任何现有的 I/O 运行时中。

底层库

imap-next 在内部使用 imap-codec 进行解析和序列化,并重新暴露了 imap-types

高级库

  • imap-proxy 是一个 IMAP 代理,它可以优雅地转发未经请求的响应,抽象处理文字,并打印 Debug 消息。
  • imap-client 是一个基于方法的客户端库,具有 client.capability()client.login(),... 接口。

用法

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:?}"),
        }
    }
}

许可证

此 crate 在 Apache 2.0 和 MIT 许可证下双许可。

感谢

感谢 NLnet 基金会 通过其 NGI Assure 计划支持 imap-next

NLnet logo Whitespace NGI Assure logo

依赖关系

~3–14MB
~183K SLoC