Struct peace_core::ItemSpecId
source · pub struct ItemSpecId(_);Expand description
Unique identifier for an ItemSpecId, Cow<'static, str> newtype.
Must begin with a letter or underscore, and contain only letters, numbers, and underscores.
Examples
The following are all examples of valid ItemSpecIds:
let _snake = item_spec_id!("snake_case");
let _camel = item_spec_id!("camelCase");
let _pascal = item_spec_id!("PascalCase");Implementations§
source§impl ItemSpecId
impl ItemSpecId
sourcepub fn new(s: &'static str) -> Result<Self, ItemSpecIdInvalidFmt<'_>>
pub fn new(s: &'static str) -> Result<Self, ItemSpecIdInvalidFmt<'_>>
Returns a new ItemSpecId if the given &str is valid.
Most users should use the item_spec_id! macro as this provides
compile time checks and returns a const value.
sourcepub fn is_valid_id(proposed_id: &str) -> bool
pub fn is_valid_id(proposed_id: &str) -> bool
Returns whether the provided &str is a valid station identifier.
Methods from Deref<Target = Cow<'static, str>>§
sourcepub fn is_borrowed(&self) -> bool
🔬This is a nightly-only experimental API. (cow_is_borrowed)
pub fn is_borrowed(&self) -> bool
cow_is_borrowed)Returns true if the data is borrowed, i.e. if to_mut would require additional work.
Examples
#![feature(cow_is_borrowed)]
use std::borrow::Cow;
let cow = Cow::Borrowed("moo");
assert!(cow.is_borrowed());
let bull: Cow<'_, str> = Cow::Owned("...moo?".to_string());
assert!(!bull.is_borrowed());sourcepub fn is_owned(&self) -> bool
🔬This is a nightly-only experimental API. (cow_is_borrowed)
pub fn is_owned(&self) -> bool
cow_is_borrowed)Returns true if the data is owned, i.e. if to_mut would be a no-op.
Examples
#![feature(cow_is_borrowed)]
use std::borrow::Cow;
let cow: Cow<'_, str> = Cow::Owned("moo".to_string());
assert!(cow.is_owned());
let bull = Cow::Borrowed("...moo?");
assert!(!bull.is_owned());Trait Implementations§
source§impl Clone for ItemSpecId
impl Clone for ItemSpecId
source§fn clone(&self) -> ItemSpecId
fn clone(&self) -> ItemSpecId
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl Debug for ItemSpecId
impl Debug for ItemSpecId
source§impl Deref for ItemSpecId
impl Deref for ItemSpecId
source§impl<'de> Deserialize<'de> for ItemSpecId
impl<'de> Deserialize<'de> for ItemSpecId
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>,
Deserialize this value from the given Serde deserializer. Read more
source§impl Display for ItemSpecId
impl Display for ItemSpecId
source§impl FromStr for ItemSpecId
impl FromStr for ItemSpecId
§type Err = ItemSpecIdInvalidFmt<'static>
type Err = ItemSpecIdInvalidFmt<'static>
The associated error which can be returned from parsing.
source§fn from_str(s: &str) -> Result<ItemSpecId, ItemSpecIdInvalidFmt<'static>>
fn from_str(s: &str) -> Result<ItemSpecId, ItemSpecIdInvalidFmt<'static>>
Parses a string
s to return a value of this type. Read moresource§impl Hash for ItemSpecId
impl Hash for ItemSpecId
source§impl PartialEq<ItemSpecId> for ItemSpecId
impl PartialEq<ItemSpecId> for ItemSpecId
source§fn eq(&self, other: &ItemSpecId) -> bool
fn eq(&self, other: &ItemSpecId) -> bool
This method tests for
self and other values to be equal, and is used
by ==.source§impl Presentable for ItemSpecId
impl Presentable for ItemSpecId
source§fn present<'output, 'life0, 'life1, 'async_trait, PR>(
&'life0 self,
presenter: &'life1 mut PR
) -> Pin<Box<dyn Future<Output = Result<(), PR::Error>> + 'async_trait>>where
PR: Presenter<'output> + 'async_trait,
Self: 'async_trait,
'output: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn present<'output, 'life0, 'life1, 'async_trait, PR>( &'life0 self, presenter: &'life1 mut PR ) -> Pin<Box<dyn Future<Output = Result<(), PR::Error>> + 'async_trait>>where PR: Presenter<'output> + 'async_trait, Self: 'async_trait, 'output: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,
Presents this data type to the user.
source§impl Serialize for ItemSpecId
impl Serialize for ItemSpecId
source§impl TryFrom<&'static str> for ItemSpecId
impl TryFrom<&'static str> for ItemSpecId
§type Error = ItemSpecIdInvalidFmt<'static>
type Error = ItemSpecIdInvalidFmt<'static>
The type returned in the event of a conversion error.
source§fn try_from(
s: &'static str
) -> Result<ItemSpecId, ItemSpecIdInvalidFmt<'static>>
fn try_from( s: &'static str ) -> Result<ItemSpecId, ItemSpecIdInvalidFmt<'static>>
Performs the conversion.
source§impl TryFrom<String> for ItemSpecId
impl TryFrom<String> for ItemSpecId
§type Error = ItemSpecIdInvalidFmt<'static>
type Error = ItemSpecIdInvalidFmt<'static>
The type returned in the event of a conversion error.
source§fn try_from(s: String) -> Result<ItemSpecId, ItemSpecIdInvalidFmt<'static>>
fn try_from(s: String) -> Result<ItemSpecId, ItemSpecIdInvalidFmt<'static>>
Performs the conversion.