Skip to content

calternal_plugin_calendar::cache

Derived calendar data and Security state stored in the Index.

Source: crates/plugins/calendar/src/cache/mod.rs

pub struct AccountRecord

No doc comment.

Fields

  • pub id: String
  • pub owner_id: String
  • pub integration_account_id: Option<String>: Shared account link; the Calendar projection ID stays stable (#407, DESIGN §49 I6).
  • pub endpoint: String
  • pub principal_href: String
  • pub calendar_home_href: String
  • pub encrypted_credential: super::EncryptedCredential
  • pub integration_credential: Option<EncryptedIntegrationCredential>: Shared encrypted credential; old calendar ciphertext is cleared after migration (#407, DESIGN §49 I6).
  • pub enabled: bool
  • pub created_ms: i64
  • pub last_sync_ms: Option<i64>
  • pub last_attempt_ms: Option<i64>
  • pub retry_after_ms: Option<i64>
  • pub last_error: Option<String>

Implements: Clone, Debug

Source: crates/plugins/calendar/src/cache/store.rs:11

pub struct CalendarChange

No doc comment.

Fields

  • pub href: String: Provider resource path, already checked against the calendar origin.
  • pub etag: Option<String>
  • pub icalendar: Option<String>
  • pub deleted: bool

Implements: Clone, Debug

Source: crates/plugins/calendar/src/cache/store.rs:71

pub struct CalendarEventMove<'a>

Provider-confirmed move of one Event between two calendars in an account.

Fields

  • pub owner_id: &'a str
  • pub account_id: &'a str
  • pub source_calendar_id: &'a str
  • pub source_href: &'a str
  • pub destination_calendar_id: &'a str
  • pub remote: &'a super::super::client::RemoteObject
  • pub now_ms: i64

Source: crates/plugins/calendar/src/cache/store.rs:115

pub struct CalendarRecord

No doc comment.

Fields

  • pub id: String
  • pub owner_id: String
  • pub account_id: String
  • pub href: String
  • pub name: String
  • pub color: Option<String>
  • pub visible: bool
  • pub sync_token: Option<String>
  • pub last_sync_ms: Option<i64>

Implements: Clone, Debug

Source: crates/plugins/calendar/src/cache/store.rs:31

pub struct CalendarSyncBatch<'a>

A provider sync page and its token commit as one cache transaction.

Fields

  • pub owner_id: &'a str
  • pub account_id: &'a str
  • pub calendar_id: &'a str
  • pub changes: &'a [CalendarChange]
  • pub sync_token: Option<&'a str>
  • pub now_ms: i64
  • pub full_snapshot: bool

Source: crates/plugins/calendar/src/cache/store.rs:104

pub struct EncryptedCredential

One encrypted credential stored in the Index.

Fields

  • pub kind: String
  • pub nonce: Vec<u8>
  • pub ciphertext: Vec<u8>

Implements: Clone, Debug

Source: crates/plugins/calendar/src/cache/crypto.rs:65

pub struct EventRecord

No doc comment.

Fields

  • pub id: String
  • pub owner_id: String
  • pub calendar_id: String
  • pub href: String
  • pub etag: String
  • pub icalendar: String
  • pub uid: Option<String>
  • pub summary: String
  • pub tags: Option<Vec<String>>: Parsed provider categories. None marks a legacy row awaiting lazy fallback.
  • pub start: Option<String>
  • pub end: Option<String>
  • pub timezone: Option<String>
  • pub location: Option<String>
  • pub all_day: bool
  • pub updated_ms: i64

Implements: Clone, Debug

Source: crates/plugins/calendar/src/cache/store.rs:44

pub struct InstanceKey(XChaCha20Poly1305, IntegrationKey);

Calendar’s dual-domain key; Debug hides its bytes (#407, DESIGN §49 I6). Its second cipher preserves compatibility with the shared Integration store.

Implements: Clone, fmt::Debug

pub fn new(key: [u8; 32]) -> Result<Self, CredentialError>

Build both Calendar and Integration ciphers from the Instance key (#407, DESIGN §49 I6).

pub fn encrypt(
&self,
owner_id: &str,
account_id: &str,
credential: &Credential,
) -> Result<EncryptedCredential, CredentialError>

Encrypt with a fresh nonce and account-bound AAD (#407, DESIGN §49 I6). Encrypt credential JSON with a fresh random 24-byte nonce (#928). Authenticated data binds the User ID, Connected Account ID, and kind; the returned nonce and ciphertext must stay with that kind. The key is Instance-owned and must not be exposed to clients (DESIGN §30).

pub fn decrypt(
&self,
owner_id: &str,
account_id: &str,
encrypted: &EncryptedCredential,
) -> Result<Credential, CredentialError>

Decrypt only when owner, account, and kind match (#407, DESIGN §49 I6). Authenticate and decode a credential for the same User and Connected Account used at encryption (#928; DESIGN §30). Reject a nonce of any length other than 24 bytes and a decoded kind that differs from the authenticated envelope. Altered context cannot decrypt the credential.

pub fn decrypt_integration(
&self,
owner_id: &str,
account_id: &str,
encrypted: &EncryptedIntegrationCredential,
) -> Result<IntegrationCredential, IntegrationCredentialError>

Decrypt the shared credential for linked services (#407, DESIGN §49 I6).

Source: crates/plugins/calendar/src/cache/crypto.rs:74

pub struct NewAccount<'a>

Inputs persisted together when a user adds a provider account.

Fields

  • pub owner_id: &'a str
  • pub id: &'a str
  • pub endpoint: &'a str
  • pub principal_href: &'a str
  • pub calendar_home_href: &'a str
  • pub credential: &'a super::EncryptedCredential
  • pub calendars: &'a [super::super::client::RemoteCalendar]
  • pub now_ms: i64

Source: crates/plugins/calendar/src/cache/store.rs:80

pub struct NewIntegratedAccount<'a>

Calendar projection persisted with a shared account (#407, DESIGN §49).

Fields

  • pub owner_id: &'a str
  • pub id: &'a str
  • pub endpoint: &'a str
  • pub principal_href: &'a str
  • pub calendar_home_href: &'a str
  • pub calendars: &'a [super::super::client::RemoteCalendar]
  • pub enabled: bool
  • pub now_ms: i64

Source: crates/plugins/calendar/src/cache/store.rs:92

pub struct VisibleEventRecord

An Event from an enabled account and visible Calendar, with its display name.

Fields

  • pub event: EventRecord
  • pub calendar_name: String

Implements: Clone, Debug

Source: crates/plugins/calendar/src/cache/store.rs:65

pub enum Credential

The credential forms supported by the storage envelope.

The OAuth variant reserves the migration path; this job accepts only Basic credentials with an app-specific password.

Variants

  • Basic { username: String, app_password: String, }
  • OAuth2 { access_token: String, refresh_token: String, }

Implements: Clone, Serialize, Deserialize, fmt::Debug

pub fn kind(&self) -> &'static str

Return the stable storage kind used in authenticated data (#407, DESIGN §49 I6).

pub fn basic(&self) -> Option<(&str, &str)>

Borrow Basic fields for the current CalDAV client, or report OAuth (#407, DESIGN §49 I6).

Source: crates/plugins/calendar/src/cache/crypto.rs:22

pub enum CredentialError

Safe failures during legacy or shared Calendar credential handling (#407, DESIGN §49 I6).

Variants

  • InvalidKey
  • RandomSource
  • Serialization
  • Authentication
  • KindMismatch

Implements: Clone, Copy, Debug, PartialEq, Eq, fmt::Display, std::error::Error

Source: crates/plugins/calendar/src/cache/crypto.rs:84

pub async fn apply_calendar_sync(db: &Db, batch: CalendarSyncBatch<'_>) -> Result<(), sqlx::Error>

No doc comment.

Source: crates/plugins/calendar/src/cache/store.rs:594

pub async fn create_integrated_account(
transaction: &mut sqlx::Transaction<'_, sqlx::Sqlite>,
account: NewIntegratedAccount<'_>,
) -> Result<(), sqlx::Error>

Add Calendar’s projection in the shared account transaction (#407, DESIGN §49).

Source: crates/plugins/calendar/src/cache/store.rs:256

pub async fn delete_account(db: &Db, owner_id: &str, id: &str) -> Result<bool, sqlx::Error>

Delete account. Commit access state on FULL before acknowledgement. Reserve the write lock before reads to avoid stale snapshots (#824, DESIGN §2).

Source: crates/plugins/calendar/src/cache/store.rs:399

pub async fn get_account(
db: &Db,
owner_id: &str,
id: &str,
) -> Result<Option<AccountRecord>, sqlx::Error>

No doc comment.

Source: crates/plugins/calendar/src/cache/store.rs:175

pub async fn get_calendar(
db: &Db,
owner_id: &str,
id: &str,
) -> Result<Option<CalendarRecord>, sqlx::Error>

No doc comment.

Source: crates/plugins/calendar/src/cache/store.rs:328

pub async fn get_event(
db: &Db,
owner_id: &str,
id: &str,
) -> Result<Option<EventRecord>, sqlx::Error>

No doc comment.

Source: crates/plugins/calendar/src/cache/store.rs:429

pub async fn get_event_by_href(
db: &Db,
owner_id: &str,
calendar_id: &str,
href: &str,
) -> Result<Option<EventRecord>, sqlx::Error>

No doc comment.

Source: crates/plugins/calendar/src/cache/store.rs:446

pub async fn list_accounts(db: &Db, owner_id: &str) -> Result<Vec<AccountRecord>, sqlx::Error>

No doc comment.

Source: crates/plugins/calendar/src/cache/store.rs:158

pub async fn list_alarm_events(db: &Db, owner_id: &str) -> Result<Vec<EventRecord>, sqlx::Error>

Read every visible cached Event that has a VALARM for one User.

Source: crates/plugins/calendar/src/cache/store.rs:500

pub async fn list_calendars(db: &Db, owner_id: &str) -> Result<Vec<CalendarRecord>, sqlx::Error>

No doc comment.

Source: crates/plugins/calendar/src/cache/store.rs:317

pub async fn list_event_owners(db: &Db) -> Result<Vec<String>, sqlx::Error>

List User IDs that have at least one cached CalDAV Event with a VALARM.

The Notifications Plugin uses this cache projection to scan explicit VALARM triggers without opening provider connections or reading Homes.

Source: crates/plugins/calendar/src/cache/store.rs:486

pub async fn list_events(db: &Db, owner_id: &str) -> Result<Vec<EventRecord>, sqlx::Error>

No doc comment.

Source: crates/plugins/calendar/src/cache/store.rs:465

pub async fn list_visible_events_in_range(
db: &Db,
owner_id: &str,
from_day: i64,
to_day: i64,
from_seconds: i64,
to_seconds: i64,
) -> Result<(Vec<VisibleEventRecord>, bool), sqlx::Error>

Return only series whose cached occurrence envelope can overlap this window. The caller widens instant bounds to cover the largest UTC offset difference; final membership is checked after recurrence expansion.

Source: crates/plugins/calendar/src/cache/store.rs:518

pub async fn mark_account_sync_failed(
db: &Db,
owner_id: &str,
id: &str,
safe_error: &str,
attempted_ms: i64,
retry_after_ms: Option<i64>,
) -> Result<(), sqlx::Error>

No doc comment.

Source: crates/plugins/calendar/src/cache/store.rs:757

pub fn migrations() -> MigrationSet

No doc comment.

Source: crates/plugins/calendar/src/cache/store.rs:125

pub async fn move_cached_event(
db: &Db,
movement: CalendarEventMove<'_>,
) -> Result<(), sqlx::Error>

Update both calendar rows atomically after the provider confirms a MOVE.

Source: crates/plugins/calendar/src/cache/store.rs:679

pub fn rewrap_legacy_credential(
owner_id: &str,
account_id: &str,
encrypted: &EncryptedCredential,
instance_key: &[u8; 32],
integration_key: &IntegrationKey,
) -> Result<EncryptedIntegrationCredential, CredentialError>

Re-wrap one pre-Connected-Accounts Calendar sign-in without logging it. Calendar’s credential kind is part of its old AAD, while Connected Accounts uses one shared AAD. Preserve OAuth tokens even though the current CalDAV client still rejects OAuth credentials (#407, DESIGN §49 I6).

Source: crates/plugins/calendar/src/cache/crypto.rs:208

pub async fn set_account_enabled(
db: &Db,
owner_id: &str,
id: &str,
enabled: bool,
) -> Result<bool, sqlx::Error>

Set account enabled. Keep credential/access changes durable before ACK (#824, DESIGN §2).

Source: crates/plugins/calendar/src/cache/store.rs:359

pub async fn set_calendar_preferences(
db: &Db,
owner_id: &str,
id: &str,
color: Option<&str>,
visible: Option<bool>,
) -> Result<bool, sqlx::Error>

No doc comment.

Source: crates/plugins/calendar/src/cache/store.rs:375

pub async fn store_account(db: &Db, account: NewAccount<'_>) -> Result<(), sqlx::Error>

Store account. Commit access state on FULL before acknowledgement. Reserve the write lock before reads to avoid stale snapshots (#824, DESIGN §2).

Source: crates/plugins/calendar/src/cache/store.rs:230

pub async fn upsert_discovered_calendars(
db: &Db,
owner_id: &str,
account_id: &str,
calendars: &[super::super::client::RemoteCalendar],
) -> Result<(), sqlx::Error>

No doc comment.

Source: crates/plugins/calendar/src/cache/store.rs:282