db/herodb/src/models/mcc/README.md
2025-04-04 10:59:51 +02:00

2.3 KiB

MCC (Mail, Calendar, Contacts) Core Models

This directory contains the core data structures used in the herolib MCC module. These models serve as the foundation for the mail, calendar, and contacts functionality.

Overview

The core models implement the Serde traits (Serialize/Deserialize) and crate database traits (Storable, SledModel), which allows them to be stored and retrieved using the generic SledDB implementation. Each model provides:

  • A struct definition with appropriate fields
  • Serde serialization through derive macros
  • Methods for database integration through the SledModel trait
  • Utility methods for common operations

Core Models

Mail (mail.rs)

The Mail models provide email and IMAP functionality:

  • Email: Main struct for email messages with IMAP metadata
  • Attachment: Represents a file attachment with file information
  • Envelope: Represents an IMAP envelope structure with message headers

Calendar (calendar.rs)

The Calendar model represents a container for calendar events:

  • Calendar: Main struct with fields for identification and description

Event (event.rs)

The Event model provides calendar event management:

  • Event: Main struct for calendar events with time and attendee information
  • EventMeta: Contains additional metadata for synchronization and display

Contacts (contacts.rs)

The Contacts model provides contact management:

  • Contact: Main struct for contact information with personal details and grouping

Usage

These models are used by the MCC module to manage emails, calendar events, and contacts. They are typically accessed through the database handlers that implement the generic SledDB interface.

Serialization

All models use Serde for serialization:

  • Each model implements Serialize and Deserialize traits through derive macros
  • Binary serialization is handled automatically by the database layer
  • JSON serialization is available for API responses and other use cases

Database Integration

The models are designed to work with the SledDB implementation through:

  • The Storable trait for serialization/deserialization
  • The SledModel trait for database operations:
    • get_id() method for unique identification
    • db_prefix() method to specify the collection prefix
  • Implementation of custom utility methods where needed