jonhoo / jonhoo/rust-imap

Add abstraction for connection to "hide away" that whether the connection is TCP, or TLS.

Open
#244 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
583
Forks
94
PR merge metrics
No merged PRs in 30d

Description

Currently the way the data types are for rust-imap you must *know* the exact type of connection you will be using and which tls implementation you are going to use in order to define your types.

I would like to make a PR that abstracts that all away into an enum so that it is hidden from the user.

A user should be able to do something like this.

```rust
let mut builder = ClientBuilder::new(
self.config.imap_host.as_ref().unwrap(),
self.config.imap_port,
);
if use_starttls {
// tag that we want start tls
builder.starttls();
} else if use_ssl {
// tag that we are doing FULL ssl mode
builder.ssl();
}
// otherwise we are doing RAW tcp (still valid as it is useful for internal only connections)

// connects and returns an opaque ImapClient that abstracts away the Tcp stream type)
let client : ImapClient = builder.connect()?;
// connects and returns an opaque ImapSession that abstracts away the Tcp stream type)
let session : ImapSession = client.login("user", "pass")?;
```

Other crates do this and it greatly simplifies client-code as I don't have to know how I compiled the code in order to connect. And I can choose to conditionally connect via SSL / TLS / raw.

One example is ldap3, which uses a simple ENUM to differentiate between Tcp, Tls, and Unix sockets (imap would only need the 2).

Let me know if you are open to this and I can build up a PR.

Contributor guide

No contributing guide indexed for this repository

Research direction

No files or tests are named in the issue. Start by locating rust-imap's connection and client/session type definitions, then compare the existing TCP and TLS paths with the proposed enum abstraction; done means callers can choose raw TCP, STARTTLS, or SSL without knowing the concrete stream or TLS implementation types.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
networking
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.