Data model
What Katlendar keeps, in which file, and which fields go to a server.
Everything lives in src/model/. The app keeps all of it in memory and writes it whole on every change.
Two files#
| File | Holds | Written by |
|---|---|---|
data.json | events, tasks, calendars, task lists, frames, accounts, the outbox | Data::save |
config.json | settings (Prefs) | Data::save, beside it |
Older copies kept the settings inside data.json. The prefs field there is still read so those files load, then settings move to config.json.
Neither file ever holds a password, a token or a private link. Those go to the keyring (see Secrets). A calendar whose link is private has url_secret set, and data.json holds keyring: (SECRET_URL) in place of the link.
Data#
| Field | What it is |
|---|---|
events | every event, from every calendar |
tasks | every task, from every list |
calendars | one's own calendars, subscribed feeds and synced calendars |
lists | task lists; list 0 is the Inbox |
frames | frames: time set aside for kinds of tasks |
accounts | synced accounts |
outbox | events deleted here that a server still has (PendingDelete) |
next_id | the last id handed out by Data::new_id |
Ids are u64 and never reused. Events and frames point at a calendar by its id, and tasks at a list by its id.
Calendars and accounts#
A calendar is one of three kinds:
- own: no
urland noaccount. - subscribed: it has a
url. Its events are read-only and are read whole each time. - synced: it has an
account.remote_idis its address on the server, andsync_stateandctaglet a pull ask only for what changed.
A frame always sits in a calendar of one's own, never in a subscribed one.
An Account names its kind with one flag: google, microsoft, nextcloud, proton or todoist. With none set it is a plain CalDAV account. client_id holds an ID the person brought for Google or Microsoft.
Fields that stay here#
Some fields are never sent to a server. Keep it that way, or the server copy of someone's calendar fills with things only Katlendar understands.
| Type | Kept here only |
|---|---|
Event | skipped, side_notes, buffer, series |
Task | color, due_order |
raw holds the event or task as the server sent it. Writing back starts from it, so fields Katlendar doesn't know are not lost. dirty marks a change the server hasn't seen yet.
Worked out, never saved#
- Buffers (
buffer.rs): free minutes before and after events. Worked out from the events whenever they are needed. - Block colours (
colors.rs): from a task's tags, its list or its calendar, in the order the person chose. - Plans (
plan.rs): the simple planner that finds free time and fits tasks into it.
Other model files#
| File | What it holds |
|---|---|
repeat.rs | repeat patterns, the custom rule and how a repeat ends |
quick.rs | the little language of the quick task field |
tags.rs | tags, gathered from tasks, frames and the planner; renamed or merged everywhere at once |
place.rs | places, map providers and where a place opens |
sample.rs | what a first start shows, and what screenshots and tests use |
tests.rs | the model's tests |
Changing the format#
data.json from any older copy must still load. When you rename or reshape a field:
- give new fields
#[serde(default)]; - move old data in a migration such as
Data::migrateorData::migrate_places; - add a test in
src/model/tests.rsthat loads the old shape.