Skip to main content

Module record

Module record 

Source
Expand description

The core usage record, and the vocabulary that classifies it.

§Duration is not closed − opened

The duration a record carries is the chargeable one, measured from answer. A 45-second ring followed by 10 seconds of conversation is a 10-second call across a 55-second wall-clock span. Deriving duration by subtraction over-bills every answered call and invents duration for every unanswered one, so UsageRecord::duration is a field and UsageRecord::wall_clock_span is a separate, differently-named accessor. Nothing falls back from one to the other.

let call = UsageRecord::new(
    RecordType::OriginatedCall,
    party,
    "2026-07-28T10:00:00+02:00".parse().unwrap(),
    source,
)
.with_closed("2026-07-28T10:00:55+02:00".parse().unwrap())
.with_duration(Seconds::new(10));

assert_eq!(call.duration, Some(Seconds::new(10)));           // billed
assert_eq!(call.wall_clock_span(), Some(Seconds::new(55)));  // observed
assert_eq!(call.service(), ServiceDomain::Voice);            // derived

§The service domain is derived, not stored

RecordType::service_domain is total, so a service field alongside the record type would be a second copy of the same fact — and two copies of one fact eventually disagree. Deriving it removes the disagreement rather than adding a rule to detect it.

§Provenance is mandatory

SourceRef is not optional and not decorative. When a billing dispute reaches an auditor two years later the question is always which file, from which node, at which offset produced this line — and a record that cannot answer it is not evidence.

Structs§

NodeId
The network element that produced a record file.
SourceRef
Where a record came from: which node, which file, which position.
UsageRecord
One unit of usage, normalised out of whatever format carried it.

Enums§

CallDirection
Which way a call went, from the served subscriber’s side.
PrimaryMeasure
The quantity that principally measures a service.
RecordType
The specific kind of record, within a ServiceDomain.
ServiceDomain
What kind of service produced a usage record.