Skip to main content

PortableCapacityDocument

Struct PortableCapacityDocument 

Source
pub struct PortableCapacityDocument {
    pub format: String,
    pub version: u32,
    pub scopes: Vec<PortableCapacityScope>,
    pub snapshots: Vec<PortableCapacitySnapshot>,
    pub history: Vec<PortableCapacityHistoryEvent>,
    pub diagnostics: Vec<PortableCapacityDiagnostic>,
    pub extensions: PortableExtensions,
    pub unknown: PortableExtensions,
}
Expand description

Everything the local capacity surfaces know, in one versioned document.

Fields§

§format: String

The format marker: FORMAT.

§version: u32

The format version: VERSION.

§scopes: Vec<PortableCapacityScope>

One row per configured scope, in [capacity] declaration order.

§snapshots: Vec<PortableCapacitySnapshot>

Every closed cycle’s immutable evidence, in snapshot order.

§history: Vec<PortableCapacityHistoryEvent>

Every capacity lifecycle event, in cycle order then file (append) order.

§diagnostics: Vec<PortableCapacityDiagnostic>

Document-level findings (preserved metadata, unsupported remote fields, version).

§extensions: PortableExtensions

Document-level keys this build preserved, in a namespace of their own.

§unknown: PortableExtensions

Keys a newer writer placed directly on the document, preserved verbatim.

Implementations§

Source§

impl PortableCapacityDocument

Source

pub fn build( config: &Config, root: &Path, index: &ScheduleIndex, snapshot: &IssueSnapshot, ) -> Result<Self>

Build the whole local capacity document: every configured scope with its calculation, every closed cycle’s evidence, every capacity lifecycle event, and the remote-target diagnostics.

snapshot is the one-pass issue snapshot the caller already built with index (the same pair tix capacity calculate uses), so a scope’s numbers are the shared calculation’s and a multi-scope export still indexes the issues once (NFR-001). The read path touches the snapshot store and the cycle records and writes nothing.

Source

pub fn build_for_cycle( config: &Config, root: &Path, index: &ScheduleIndex, snapshot: &IssueSnapshot, reference: &str, ) -> Result<Self>

Build the document for one cycle: the scope that configures it, its immutable evidence and its lifecycle history.

The reference is what the caller wrote — a generated cycle’s name or its stable id — and it is folded through the same adapter every other surface uses, so the two spellings select one document (C-003). A reference nothing resolves to is a not_found, not an empty document.

Source

pub fn is_empty(&self) -> bool

Whether this document carries no capacity at all.

Source

pub fn format(&self) -> &str

The document’s format marker.

Source

pub const fn version(&self) -> u32

The document’s format version.

Source

pub fn insert_extension(&mut self, key: impl Into<String>, value: Value)

Preserve one document-level key, in the nested extensions object.

The only public write path into a bag, and it cannot produce a document this build cannot read: the key lands in a namespace of its own, so it can never duplicate — or be read in place of — a document field.

Source

pub fn to_json(&self) -> Result<String>

Serialize the document as compact JSON.

Source

pub fn to_json_pretty(&self) -> Result<String>

Serialize the document as pretty JSON — the export surface’s shape.

Source

pub fn from_json(raw: &str) -> Result<Self>

Read a document back.

The [Marker] is read first: a document that is not a capacity document is refused by name (its format marker) rather than by whatever shape error its fields happened to raise — a tix-health or tix-roadmap payload overlaps structurally and used to produce a misleading field error. A document of another version is read, its own fields and preserved keys kept, and the mismatch is merged into the diagnostics once — the checked-and-reported third answer between refusing a newer writer and silently dropping its fields.

Trait Implementations§

Source§

impl Clone for PortableCapacityDocument

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PortableCapacityDocument

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for PortableCapacityDocument

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for PortableCapacityDocument

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for PortableCapacityDocument

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for PortableCapacityDocument

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.