mail2couch/rust
Ole-Morten Duesund 8764b44a05 feat: implement comprehensive environment variable credential support
- Add environment variable overrides for sensitive credentials in both Go and Rust implementations
- Support MAIL2COUCH_COUCHDB_USER and MAIL2COUCH_COUCHDB_PASSWORD for CouchDB credentials
- Support MAIL2COUCH_IMAP_<NAME>_USER and MAIL2COUCH_IMAP_<NAME>_PASSWORD for IMAP credentials
- Implement automatic name normalization for mail source names to environment variable format
- Add runtime display of active environment variable overrides
- Enhance --help output in both implementations with comprehensive environment variable documentation
- Add detailed environment variable section to README with usage examples and security benefits
- Create comprehensive ENVIRONMENT_VARIABLES.md reference guide with SystemD, Docker, and CI/CD examples
- Update all documentation indices and cross-references
- Include security best practices and troubleshooting guidance
- Maintain full backward compatibility with existing configuration files

This enhancement addresses the high-priority security requirement to eliminate plaintext
passwords from configuration files while providing production-ready credential management
for both development and deployment scenarios.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-07 15:09:34 +02:00
..
src feat: implement comprehensive environment variable credential support 2025-08-07 15:09:34 +02:00
Cargo.toml feat: implement just-based build system with distinct binary names 2025-08-03 19:01:42 +02:00
config-gmail-example.json feat: add TLS support to Rust implementation 2025-08-02 20:01:42 +02:00
config-test-rust-no-filter.json feat: fix attachment stub issues in Rust implementation 2025-08-03 13:52:55 +02:00
config-test-rust-single.json feat: fix attachment stub issues in Rust implementation 2025-08-03 13:52:55 +02:00
config-test-rust.json feat: add comprehensive Rust implementation with feature parity 2025-08-02 20:27:14 +02:00
config-tls-test.json feat: add TLS support to Rust implementation 2025-08-02 20:01:42 +02:00
README.md docs: add comprehensive CouchDB schema documentation for cross-implementation compatibility 2025-08-02 15:08:35 +02:00
TLS_SUPPORT.md feat: add TLS support to Rust implementation 2025-08-02 20:01:42 +02:00

Mail2Couch Rust Implementation

This directory contains the Rust implementation of mail2couch, which will provide the same functionality as the Go implementation while maintaining full compatibility with the CouchDB document schemas.

Current Status

🚧 Work in Progress - The Rust implementation is planned for future development.

Currently available:

  • CouchDB Schema Definitions: Complete Rust structs that match the Go implementation
  • Serialization Support: Full serde integration for JSON handling
  • Type Safety: Strongly typed structures for all CouchDB documents
  • Compatibility Tests: Validated against example documents
  • Database Naming: Same database naming logic as Go implementation

Schema Compatibility

The Rust implementation uses the same CouchDB document schemas as the Go implementation:

Mail Documents

use mail2couch::{MailDocument, generate_database_name};

let mut doc = MailDocument::new(
    "123".to_string(),        // IMAP UID
    "INBOX".to_string(),      // Mailbox
    vec!["sender@example.com".to_string()],  // From
    vec!["recipient@example.com".to_string()], // To
    "Subject".to_string(),    // Subject
    Utc::now(),              // Date
    "Body content".to_string(), // Body
    HashMap::new(),          // Headers
    false,                   // Has attachments
);

doc.set_id(); // Sets ID to "INBOX_123"

Sync Metadata

use mail2couch::SyncMetadata;

let metadata = SyncMetadata::new(
    "INBOX".to_string(),     // Mailbox
    Utc::now(),             // Last sync time
    456,                    // Last message UID
    100,                    // Message count
);
// ID automatically set to "sync_metadata_INBOX"

Database Naming

use mail2couch::generate_database_name;

let db_name = generate_database_name("Personal Gmail", "");
// Returns: "m2c_personal_gmail"

let db_name = generate_database_name("", "user@example.com");
// Returns: "m2c_user_example_com"

Dependencies

The Rust implementation uses these key dependencies:

  • serde: JSON serialization/deserialization
  • chrono: Date/time handling with ISO8601 support
  • reqwest: HTTP client for CouchDB API
  • tokio: Async runtime
  • anyhow/thiserror: Error handling

Testing

Run the schema compatibility tests:

cargo test

All tests validate that the Rust structures produce JSON compatible with the Go implementation and documented schemas.

Future Implementation

The planned Rust implementation will include:

  • IMAP Client: Connect to mail servers and retrieve messages
  • CouchDB Integration: Store documents using native Rust CouchDB client
  • Configuration: Same JSON config format as Go implementation
  • CLI Interface: Compatible command-line interface
  • Performance: Leveraging Rust's performance characteristics
  • Memory Safety: Rust's ownership model for reliable operation

Schema Documentation

See the following files for complete schema documentation:

Cross-Implementation Compatibility

Both Go and Rust implementations:

  • Use identical CouchDB document schemas
  • Generate the same database names
  • Store documents with the same field names and types
  • Support incremental sync with compatible metadata
  • Handle attachments using CouchDB native attachment storage

This ensures that databases created by either implementation can be used interchangeably.