Search

Lib.rs

› Email
#data-stream #pop3 #transaction #authorization #parser #hash #1939

rfc1939

Parsing RFC 1939 (i.e. POP3) data streams

Owned by Cyan.

  • Install
  • API reference
  • GitHub repo (coalooball)

2 releases (1 stable)

1.0.0 Dec 22, 2023
0.1.0 Dec 22, 2023

#413 in Email

MIT/Apache

63KB
1.5K SLoC

A library for parsing byte data streams implemented according to RFC 1939.

Usage

All commands and reponses are categorized into three sections: AUTHORIZATION, TRANSACTION and UPDATE.

Command Examples
use rfc1939::authorization::command::*;
use rfc1939::transaction::command::*;
use rfc1939::types::command::*;

assert_eq!(user(b"USER name\r\n").unwrap(), User { name: b"name" });
assert_eq!(pass(b"PASS pwd\r\n").unwrap(), Pass { string: b"pwd" });
assert_eq!(
    apop(b"APOP mrose c4c9334bac560ecc979e58001b3e22fb\r\n").unwrap(),
    Apop {
        name: b"mrose",
        digest: b"c4c9334bac560ecc979e58001b3e22fb"
    }
);
assert_eq!(stat(b"stat\r\n").unwrap(), Stat);
assert_eq!(list(b"LIST 2222\r\n").unwrap(), List { msg: Some(2222) });
assert_eq!(retr(b"RETR 1\r\n").unwrap(), Retr { msg: 1 });
assert_eq!(dele(b"DELE 1\r\n").unwrap(), Dele { msg: 1 });
assert_eq!(noop(b"NOOP\r\n").unwrap(), Noop);
assert_eq!(rset(b"RSET\r\n").unwrap(), Rset);
assert_eq!(top(b"TOP 1 10\r\n").unwrap(), Top { msg: 1, n: 10 });
assert_eq!(uidl(b"UIDL 1\r\n").unwrap(), Uidl { msg: Some(1) });
Response Example
use rfc1939::transaction::response::retr;
use rfc1939::types::response::Retr;
use rfc1939::common::StatusIndicator;
assert_eq!(
    retr(b"+OK 120 octets\r\n<the POP3 server sends the entire message here>\r\n.\r\n")
        .unwrap(),
    Retr {
        status_indicator: StatusIndicator::OK,
        message: Some(b"<the POP3 server sends the entire message here>"),
        information: b"120 octets"
    }
);

Dependencies

~1MB
~18K SLoC

  • nom
Related: imap_bodystructure
See also: stalwart-cli, weezl, aws-sdk-kinesis, google-datastream1, polkadot-p2p-connect, google-datastream1-cli, mft, dings, guacamole, aws_utils_kinesis_data_streams, rustyphoenixdatastream

Lib.rs is an unofficial list of Rust/Cargo crates, created by kornelski. It contains data from multiple sources, including heuristics, and manually curated data. Content of this page is not necessarily endorsed by the authors of the crate. This site is not affiliated with nor endorsed by the Rust Project. If something is missing or incorrect, please file a bug.