Expand description
Product-agnostic media-primitive schema.
The architectural hub is the hand-written domain layer; every
backend — protobuf wire (under [buffa]), sqlx row mappers
(under [sqlx]), MongoDB (under [mongodb]) — is a thin lossless
conversion to/from the domain. Locked schema docs live under
schema/*.md; they are the specification the implementation tracks.
Encode-side bridges (From<&Domain> for Backend) are infallible —
the domain is the validated side. Decode-side bridges
(TryFrom<Backend> for Domain) route through the same try_new +
with_* builders application code uses, so every invariant is
re-enforced at the wire/storage edge.
§Aggregate clusters
domain::Media/domain::MediaFile/domain::WatchedLocation— content-addressed media identity + per-copy locator + FS-event monitor.domain::Audio/domain::AudioTrack/domain::AudioSegment(+Wordchild) — audio cluster.domain::Video/domain::VideoTrack/domain::Scene/domain::Keyframe— video cluster.domain::Subtitle/domain::SubtitleTrack/domain::SubtitleCue<Id, D>— subtitle cluster; cues are polymorphic over the per-format payloadD(SrtData,VttData,AssData,LrcData).domain::Person/domain::Speaker— identity (per-track diarized voice with embedding-keyed voiceprint).
§Feature flags
Three independent capability tiers (alloc / std, both
additive), three medium-aggregate gates (video / audio /
subtitle), plus optional backend features. Defaults are
std + video + audio + subtitle.
| flag | role | depends on |
|---|---|---|
| none | no-std + no-alloc; stack-only types only | — |
alloc | no-std + alloc; adds heap-using domain types | — |
std (default) | adds jiff-using aggregates + Uuid::now_v7 | — |
video (default) | compiles the Video / VideoTrack / Scene / Keyframe aggregate tree + its backends | a heap tier |
audio (default) | compiles the Audio / AudioTrack / AudioSegment aggregate tree + its backends | a heap tier |
subtitle (default) | compiles the Subtitle / SubtitleTrack / SubtitleCue aggregate tree + its backends | a heap tier |
buffa | proto3 wire layer (under [buffa]) | std or alloc |
json | wire JSON via serde | std + buffa |
arbitrary | Arbitrary derives for property tests | std + buffa |
mongodb | bson backend (under [mongodb]) | std + json |
sqlx-postgres / sqlx-mysql / sqlx-sqlite | sql backends (under [sqlx]) | std |
The three medium gates are independent on/off flags: a consumer that
only needs the video aggregate tree can opt out of the audio /
subtitle trees (and all their backend bridges) with
default-features = false + features = ["std", "video"]. The
cross-cutting aggregates (Media, MediaFile, Person, Speaker,
WatchedLocation, UserTag, SceneAnnotation) plus the
Identified<Id, D> transport envelope are
always available when a heap tier is on.
§Regenerating wire code
The buffa-generated wire layer (src/generated/) is produced from
the .proto files in proto/. Regenerate with
cargo run -p xtask -- gen. Do not hand-edit the generated
files.
Re-exports§
pub use crate::domain::Identified;
Modules§
- domain
- Hand-written domain layer — the architectural hub. App logic programs
against
mediaschema::domain::*; the buffa-generated wire types at the crate root (re-exported fromgenerated::media::v1::*, available withfeature = "std") are the serialization edge. Domain ⇄ wire conversions are added incrementally as each aggregate lands (withdomain → wire → domainround-trip property tests). Seeschema/*.mdfor the locked specifications. Hand-written domain layer — the architectural hub for mediaschema.