Skip to content

calternal_notes_core::reminders

Lossless calternal-reminders frontmatter projection.

A vault file owns a mapping from reminder UUID to reminder record. The mapping lives in one JSON flow value on the existing YAML frontmatter key; JSON is valid YAML, remains readable by ordinary YAML tools, and lets this module preserve unknown fields and trigger shapes without implementing a second YAML parser. The writer edits only that frontmatter line and leaves every other byte untouched.

Source: crates/calternal-notes-core/src/reminders.rs

pub struct BlockReminderInspection

Lossless-read status returned by inspect_block_reminders.

A malformed value intentionally has no raw rewrite authority: reminders is empty and callers must leave the source bytes alone or ask a newer tool to repair them. The raw value stays in the host file, never in this parsed projection.

Fields

  • pub status: BlockReminderStatus
  • pub reminders: BlockReminderMap

Implements: Debug, Clone, PartialEq

Source: crates/calternal-notes-core/src/reminders.rs:56

pub enum BlockReminderStatus

The parse outcome for the app-owned frontmatter key.

Malformed is deliberately distinct from Absent: an older client must never treat foreign YAML or damaged JSON as an empty map and erase it on a later save. The status is serialized in lowercase for the JS API.

Variants

  • Absent
  • Valid
  • Malformed

Implements: Debug, Clone, Copy, PartialEq, Eq

Source: crates/calternal-notes-core/src/reminders.rs:43

pub type BlockReminderMap = BTreeMap<String, Value>;

A UUID-keyed map of reminder records. Records intentionally remain JSON values at this boundary: fields added by a newer client, including nested trigger fields and non-string values, must survive an older round-trip.

Source: crates/calternal-notes-core/src/reminders.rs:35

pub fn extract_block_reminders(text: &str) -> BlockReminderMap

Read the calternal-reminders mapping from a host file.

The canonical writer emits one-line JSON. A malformed or non-object value remains an empty compatibility projection. New callers should use inspect_block_reminders first and refuse mutation on Malformed; this legacy helper remains for hosts that only need the valid-map projection.

Source: crates/calternal-notes-core/src/reminders.rs:87

pub fn inspect_block_reminders(text: &str) -> BlockReminderInspection

Inspect the owned frontmatter field without conflating absence and damage.

Source: crates/calternal-notes-core/src/reminders.rs:62

pub fn set_block_reminders(text: &str, reminders: &BlockReminderMap) -> String

Write the reminder map into the existing host file’s frontmatter.

An empty map removes the owned key. Non-empty maps are emitted in sorted UUID/key order by serde_json’s BTreeMap traversal, which makes equal logical maps converge to equal bytes across devices. Unknown record fields and trigger values are serialized unchanged in type and value.

Source: crates/calternal-notes-core/src/reminders.rs:97

pub fn set_block_reminders_checked(
text: &str,
reminders: &BlockReminderMap,
) -> Result<String, &'static str>

Safely write the mapping only when the current field is absent or valid.

Unlike set_block_reminders, this is the mutation seam for hosts that cannot afford to overwrite an externally-authored or damaged value. It returns an error and leaves the input untouched when inspection reports Malformed; callers can surface that state for manual repair or a newer client. The returned error is stable enough for a UI/log category, but is not a replacement for the structured inspection status.

Source: crates/calternal-notes-core/src/reminders.rs:115

pub fn valid_block_reminder_id(value: &str) -> bool

Validate a stable block anchor before it enters the reminder projection. Block IDs are Markdown identities, not paths, so accept only bounded ASCII letters, digits, _ and -.

Source: crates/calternal-notes-core/src/reminders.rs:24

pub const REMINDERS_FRONTMATTER_KEY: &str

The only frontmatter key owned by the reminder projection.

Source: crates/calternal-notes-core/src/reminders.rs:19