pub struct CapacityConfig(/* private fields */);Expand description
The [capacity] section: capacity entries keyed by a handle, in declaration order.
Serialized transparently as the TOML table [capacity.<entry-id>] and omitted whole
when empty, so a repository that configures no capacity gains no key on save and a
legacy tix.toml round-trips byte-identically (C-001).
Implementations§
Source§impl CapacityConfig
impl CapacityConfig
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Whether no capacity is configured: the state that writes nothing.
Sourcepub fn get(&self, id: &str) -> Option<&CapacityEntry>
pub fn get(&self, id: &str) -> Option<&CapacityEntry>
One entry by its handle.
Sourcepub fn get_mut(&mut self, id: &str) -> Option<&mut CapacityEntry>
pub fn get_mut(&mut self, id: &str) -> Option<&mut CapacityEntry>
One entry by its handle, mutably.
Sourcepub fn iter(&self) -> impl Iterator<Item = (&str, &CapacityEntry)>
pub fn iter(&self) -> impl Iterator<Item = (&str, &CapacityEntry)>
The entries, in declaration order.
Sourcepub fn entries(&self) -> &IndexMap<String, CapacityEntry>
pub fn entries(&self) -> &IndexMap<String, CapacityEntry>
The entries as a map, for a caller that must serialize or compare them whole.
Sourcepub fn entries_mut(&mut self) -> &mut IndexMap<String, CapacityEntry>
pub fn entries_mut(&mut self) -> &mut IndexMap<String, CapacityEntry>
The entries mutably, for the declaration-order restoration the loader performs.
Sourcepub fn insert(
&mut self,
id: impl Into<String>,
entry: CapacityEntry,
) -> Option<CapacityEntry>
pub fn insert( &mut self, id: impl Into<String>, entry: CapacityEntry, ) -> Option<CapacityEntry>
Preserve one entry, returning the previous one if the handle was already used.
Sourcepub fn restore_declaration_order(&mut self, contents: &str)
pub fn restore_declaration_order(&mut self, contents: &str)
Restore the declaration order the toml parser loses (it sorts table keys) from
the [capacity.<entry-id>] headers in the source document.
Trait Implementations§
Source§impl Clone for CapacityConfig
impl Clone for CapacityConfig
Source§impl Debug for CapacityConfig
impl Debug for CapacityConfig
Source§impl Default for CapacityConfig
impl Default for CapacityConfig
Source§impl<'de> Deserialize<'de> for CapacityConfig
impl<'de> Deserialize<'de> for CapacityConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for CapacityConfig
Source§impl Index<&str> for CapacityConfig
Indexing by handle, so a caller that has validated a config reads
config.capacity["zulu"] the way it reads any other registry in tix.toml.
impl Index<&str> for CapacityConfig
Indexing by handle, so a caller that has validated a config reads
config.capacity["zulu"] the way it reads any other registry in tix.toml.
Panics on an unknown handle, exactly as indexing an IndexMap does: a missing entry
is a programming error by the time a caller has a handle, and CapacityConfig::get
is the total alternative.
Source§impl PartialEq for CapacityConfig
impl PartialEq for CapacityConfig
Source§impl Serialize for CapacityConfig
impl Serialize for CapacityConfig
impl StructuralPartialEq for CapacityConfig
Auto Trait Implementations§
impl Freeze for CapacityConfig
impl RefUnwindSafe for CapacityConfig
impl Send for CapacityConfig
impl Sync for CapacityConfig
impl Unpin for CapacityConfig
impl UnsafeUnpin for CapacityConfig
impl UnwindSafe for CapacityConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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