pub struct ItemId(/* private fields */);
Expand description
Unique identifier for an ItemId
, 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 ItemId
s:
let _snake = item_id!("snake_case");
let _camel = item_id!("camelCase");
let _pascal = item_id!("PascalCase");
§Design Note
TODO: Experiment with upgrades.
For backward compatibility and migrating items from old IDs to new IDs, e.g. when they were deployed with an old version of the automation software, there needs to be a way to:
- Read state using the old ID.
- Either clean up that state, or migrate that state into an Item with the new ID.
Implementations§
source§impl ItemId
impl ItemId
sourcepub fn new(s: &'static str) -> Result<ItemId, ItemIdInvalidFmt<'static>>
pub fn new(s: &'static str) -> Result<ItemId, ItemIdInvalidFmt<'static>>
Returns a new ItemId
if the given &str
is valid.
Most users should use the item_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<'de> Deserialize<'de> for ItemId
impl<'de> Deserialize<'de> for ItemId
source§fn deserialize<__D>(
__deserializer: __D
) -> Result<ItemId, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D
) -> Result<ItemId, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
source§impl PartialEq for ItemId
impl PartialEq for ItemId
source§impl Presentable for ItemId
impl Presentable for ItemId
source§fn present<'output, 'life0, 'life1, 'async_trait, PR>(
&'life0 self,
presenter: &'life1 mut PR
) -> Pin<Box<dyn Future<Output = Result<(), <PR as Presenter<'output>>::Error>> + 'async_trait>>where
'output: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
PR: Presenter<'output> + 'async_trait,
ItemId: 'async_trait,
fn present<'output, 'life0, 'life1, 'async_trait, PR>(
&'life0 self,
presenter: &'life1 mut PR
) -> Pin<Box<dyn Future<Output = Result<(), <PR as Presenter<'output>>::Error>> + 'async_trait>>where
'output: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
PR: Presenter<'output> + 'async_trait,
ItemId: 'async_trait,
source§impl Serialize for ItemId
impl Serialize for ItemId
source§fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
source§impl TryFrom<&'static str> for ItemId
impl TryFrom<&'static str> for ItemId
§type Error = ItemIdInvalidFmt<'static>
type Error = ItemIdInvalidFmt<'static>
source§impl TryFrom<String> for ItemId
impl TryFrom<String> for ItemId
§type Error = ItemIdInvalidFmt<'static>
type Error = ItemIdInvalidFmt<'static>
impl Eq for ItemId
impl StructuralPartialEq for ItemId
Auto Trait Implementations§
impl RefUnwindSafe for ItemId
impl Send for ItemId
impl Sync for ItemId
impl Unpin for ItemId
impl UnwindSafe for ItemId
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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.