imap

    IMAP4 会话、同步 literal、IDLE 与 TCP/TLS 客户端

    Download zip
    Version
    0.4.0
    License
    MIT
    Last updated
    5 hours ago
    Downloads
    1

    #可执行 API 示例

    收紧 FETCH sequence-set 语法,支持范围、星号、逗号和 32 位边界。这些例子调用公开 API,并随 moon test 执行。

    ///|
    test "sequence sets reject invalid separators and zero" {
    for s in ["1", "1:3", "3:1", "*", "1:*,7"] {
    assert_true(@imap.valid_sequence_set(s))
    }
    for s in ["0", "01", "1:", ":2", "1,,2", "1:2:3", "4294967296"] {
    assert_true(!@imap.valid_sequence_set(s))
    }
    }

    0.4 已提供 TCP/隐式 TLS/STARTTLS、APPEND/IDLE/PLAIN 和 Dovecot/GreenMail 互通。核心升级状态用法见 starttls_test.mbt;仍缺完整 FETCH 语义、更多 SASL 和其它扩展。

    ImapError

    pub suberror ImapError {
    Invalid(String)
    } derive(
    Debug
    )

    Decoder

    pub struct Decoder {
    // private fields
    } derive(
    Debug
    )

    Incremental byte parser with bounded per-response storage; literals never pass through UTF-8.

    Decoder::feed

    fn Decoder::feed(self : Decoder, bytes : Bytes) -> Array[Response] raise ImapError

    Decoder::finish

    fn Decoder::finish(self : Decoder) -> Unit raise ImapError

    Decoder::has_partial

    fn Decoder::has_partial(self : Decoder) -> Bool

    Decoder::new

    fn Decoder::new() -> Decoder

    Response

    pub(all) struct Response {
    line : String
    literals : Array[Bytes]
    } derive(Eq,
    Debug
    )

    Session

    pub struct Session {
    // private fields
    } derive(
    Debug
    )

    Session::append

    fn Session::append(self : Session, mailbox : String, size : Int, flags? : String) -> String raise ImapError

    Session::authenticate_response

    fn Session::authenticate_response(self : Session, base64 : String) -> String raise ImapError

    A pre-encoded PLAIN response or '*' to cancel. Credentials are encoded by the host.

    Session::capabilities

    fn Session::capabilities(self : Session) -> Array[String]

    Session::command

    fn Session::command(self : Session, command : String, args : Array[String]) -> String raise ImapError

    Session::done

    fn Session::done(self : Session) -> String raise ImapError

    Session::feed

    fn Session::feed(self : Session, bytes : Bytes) -> Array[Response] raise ImapError

    Session::finish

    fn Session::finish(self : Session) -> Unit raise ImapError

    Session::has_pending

    fn Session::has_pending(self : Session) -> Bool

    Session::literal

    fn Session::literal(self : Session, bytes : Bytes) -> Bytes raise ImapError

    Send a synchronizing APPEND literal only after the server's continuation.

    Session::new

    fn Session::new() -> Session

    Session::state

    fn Session::state(self : Session) -> State

    Session::tls_established

    fn Session::tls_established(self : Session) -> Unit raise ImapError

    The transport must verify the certificate and hostname before calling this method.

    State

    pub(all) enum State {
    Greeting
    NotAuthenticated
    Authenticated
    Selected
    Closed
    } derive(Eq,
    Debug
    )

    decode_mailbox

    fn decode_mailbox(encoded : String) -> String raise ImapError

    encode_mailbox

    fn encode_mailbox(name : String) -> String raise ImapError

    RFC 3501 modified UTF-7, for mailbox names before UTF8=ACCEPT negotiation.

    valid_sequence_set

    fn valid_sequence_set(s : String) -> Bool

    Validate RFC 3501 sequence-set syntax without interpreting mailbox contents.