pub struct StatusMapping { /* private fields */ }Expand description
One source’s status_mapping: for each status category it mentions, the names it gives
each item kind, or null.
Held in the contract’s category order with each category at most once, so iterating it reports in that order and a category named twice is a state it cannot hold.
Implementations§
Source§impl StatusMapping
impl StatusMapping
Sourcepub fn mentions(&self, category: StatusCategory) -> bool
pub fn mentions(&self, category: StatusCategory) -> bool
Whether the mapping mentions category, as a name or as null.
Sourcepub fn entry(&self, category: StatusCategory) -> Option<Option<&StatusNames>>
pub fn entry(&self, category: StatusCategory) -> Option<Option<&StatusNames>>
What the mapping says of category: None where it does not mention it, Some(None)
where it sets it to null, and the names otherwise.
Sourcepub fn name_for(
&self,
category: StatusCategory,
kind: ItemKind,
) -> Result<&StatusName, UnmappedStatus>
pub fn name_for( &self, category: StatusCategory, kind: ItemKind, ) -> Result<&StatusName, UnmappedStatus>
The name category is written as for kind, or why the mapping gives none.
§Errors
The UnmappedStatus saying which of the three ways the mapping gives no name.
Sourcepub fn names(
&self,
kind: ItemKind,
) -> impl Iterator<Item = (StatusCategory, &StatusName)>
pub fn names( &self, kind: ItemKind, ) -> impl Iterator<Item = (StatusCategory, &StatusName)>
Every name the mapping gives kind, with its category, in category order.
Sourcepub fn category_of(&self, kind: ItemKind, name: &str) -> Option<StatusCategory>
pub fn category_of(&self, kind: ItemKind, name: &str) -> Option<StatusCategory>
The category a kind name reads as, when the mapping names it for that kind.
Sourcepub fn distinct<'a>(
source: &SourceName,
kind: ItemKind,
names: impl IntoIterator<Item = (StatusCategory, &'a str)>,
) -> Result<(), SourceError>
pub fn distinct<'a>( source: &SourceName, kind: ItemKind, names: impl IntoIterator<Item = (StatusCategory, &'a str)>, ) -> Result<(), SourceError>
Refuse two categories sent to one name of one kind, ignoring case: that name could read back as only one of them.
Takes the names to compare rather than reading this mapping’s own, so a source whose unmentioned categories keep shipped defaults compares what it really resolves to.
§Errors
SourceError::Config naming the source, the kind, both categories and the name.
Trait Implementations§
Source§impl Clone for StatusMapping
impl Clone for StatusMapping
Source§impl Debug for StatusMapping
impl Debug for StatusMapping
Source§impl Default for StatusMapping
impl Default for StatusMapping
Source§impl<'de> Deserialize<'de> for StatusMapping
impl<'de> Deserialize<'de> for StatusMapping
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
impl Eq for StatusMapping
Source§impl JsonSchema for StatusMapping
impl JsonSchema for StatusMapping
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read more