calternal_plugin_calendar::cache
Derived calendar data and Security state stored in the Index.
Source: crates/plugins/calendar/src/cache/mod.rs
Structs
Section titled “Structs”AccountRecord
Section titled “AccountRecord”pub struct AccountRecordNo doc comment.
Fields
pub id: Stringpub owner_id: Stringpub integration_account_id: Option<String>: Shared account link; the Calendar projection ID stays stable (#407, DESIGN §49 I6).pub endpoint: Stringpub principal_href: Stringpub calendar_home_href: Stringpub encrypted_credential: super::EncryptedCredentialpub integration_credential: Option<EncryptedIntegrationCredential>: Shared encrypted credential; old calendar ciphertext is cleared after migration (#407, DESIGN §49 I6).pub enabled: boolpub created_ms: i64pub 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
CalendarChange
Section titled “CalendarChange”pub struct CalendarChangeNo 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
CalendarEventMove
Section titled “CalendarEventMove”pub struct CalendarEventMove<'a>Provider-confirmed move of one Event between two calendars in an account.
Fields
pub owner_id: &'a strpub account_id: &'a strpub source_calendar_id: &'a strpub source_href: &'a strpub destination_calendar_id: &'a strpub remote: &'a super::super::client::RemoteObjectpub now_ms: i64
Source: crates/plugins/calendar/src/cache/store.rs:115
CalendarRecord
Section titled “CalendarRecord”pub struct CalendarRecordNo doc comment.
Fields
pub id: Stringpub owner_id: Stringpub account_id: Stringpub href: Stringpub name: Stringpub color: Option<String>pub visible: boolpub sync_token: Option<String>pub last_sync_ms: Option<i64>
Implements: Clone, Debug
Source: crates/plugins/calendar/src/cache/store.rs:31
CalendarSyncBatch
Section titled “CalendarSyncBatch”pub struct CalendarSyncBatch<'a>A provider sync page and its token commit as one cache transaction.
Fields
pub owner_id: &'a strpub account_id: &'a strpub calendar_id: &'a strpub changes: &'a [CalendarChange]pub sync_token: Option<&'a str>pub now_ms: i64pub full_snapshot: bool
Source: crates/plugins/calendar/src/cache/store.rs:104
EncryptedCredential
Section titled “EncryptedCredential”pub struct EncryptedCredentialOne encrypted credential stored in the Index.
Fields
pub kind: Stringpub nonce: Vec<u8>pub ciphertext: Vec<u8>
Implements: Clone, Debug
Source: crates/plugins/calendar/src/cache/crypto.rs:65
EventRecord
Section titled “EventRecord”pub struct EventRecordNo doc comment.
Fields
pub id: Stringpub owner_id: Stringpub calendar_id: Stringpub href: Stringpub etag: Stringpub icalendar: Stringpub uid: Option<String>pub summary: Stringpub tags: Option<Vec<String>>: Parsed provider categories.Nonemarks 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: boolpub updated_ms: i64
Implements: Clone, Debug
Source: crates/plugins/calendar/src/cache/store.rs:44
InstanceKey
Section titled “InstanceKey”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
InstanceKey::new
Section titled “InstanceKey::new”pub fn new(key: [u8; 32]) -> Result<Self, CredentialError>Build both Calendar and Integration ciphers from the Instance key (#407, DESIGN §49 I6).
InstanceKey::encrypt
Section titled “InstanceKey::encrypt”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).
InstanceKey::decrypt
Section titled “InstanceKey::decrypt”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.
InstanceKey::decrypt_integration
Section titled “InstanceKey::decrypt_integration”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
NewAccount
Section titled “NewAccount”pub struct NewAccount<'a>Inputs persisted together when a user adds a provider account.
Fields
pub owner_id: &'a strpub id: &'a strpub endpoint: &'a strpub principal_href: &'a strpub calendar_home_href: &'a strpub credential: &'a super::EncryptedCredentialpub calendars: &'a [super::super::client::RemoteCalendar]pub now_ms: i64
Source: crates/plugins/calendar/src/cache/store.rs:80
NewIntegratedAccount
Section titled “NewIntegratedAccount”pub struct NewIntegratedAccount<'a>Calendar projection persisted with a shared account (#407, DESIGN §49).
Fields
pub owner_id: &'a strpub id: &'a strpub endpoint: &'a strpub principal_href: &'a strpub calendar_home_href: &'a strpub calendars: &'a [super::super::client::RemoteCalendar]pub enabled: boolpub now_ms: i64
Source: crates/plugins/calendar/src/cache/store.rs:92
VisibleEventRecord
Section titled “VisibleEventRecord”pub struct VisibleEventRecordAn Event from an enabled account and visible Calendar, with its display name.
Fields
pub event: EventRecordpub calendar_name: String
Implements: Clone, Debug
Source: crates/plugins/calendar/src/cache/store.rs:65
Credential
Section titled “Credential”pub enum CredentialThe 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
Credential::kind
Section titled “Credential::kind”pub fn kind(&self) -> &'static strReturn the stable storage kind used in authenticated data (#407, DESIGN §49 I6).
Credential::basic
Section titled “Credential::basic”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
CredentialError
Section titled “CredentialError”pub enum CredentialErrorSafe failures during legacy or shared Calendar credential handling (#407, DESIGN §49 I6).
Variants
InvalidKeyRandomSourceSerializationAuthenticationKindMismatch
Implements: Clone, Copy, Debug, PartialEq, Eq, fmt::Display, std::error::Error
Source: crates/plugins/calendar/src/cache/crypto.rs:84
Functions
Section titled “Functions”apply_calendar_sync
Section titled “apply_calendar_sync”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
create_integrated_account
Section titled “create_integrated_account”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
delete_account
Section titled “delete_account”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
get_account
Section titled “get_account”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
get_calendar
Section titled “get_calendar”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
get_event
Section titled “get_event”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
get_event_by_href
Section titled “get_event_by_href”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
list_accounts
Section titled “list_accounts”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
list_alarm_events
Section titled “list_alarm_events”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
list_calendars
Section titled “list_calendars”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
list_event_owners
Section titled “list_event_owners”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
list_events
Section titled “list_events”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
list_visible_events_in_range
Section titled “list_visible_events_in_range”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
mark_account_sync_failed
Section titled “mark_account_sync_failed”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
migrations
Section titled “migrations”pub fn migrations() -> MigrationSetNo doc comment.
Source: crates/plugins/calendar/src/cache/store.rs:125
move_cached_event
Section titled “move_cached_event”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
rewrap_legacy_credential
Section titled “rewrap_legacy_credential”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
set_account_enabled
Section titled “set_account_enabled”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
set_calendar_preferences
Section titled “set_calendar_preferences”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
store_account
Section titled “store_account”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
upsert_discovered_calendars
Section titled “upsert_discovered_calendars”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.