Struct peace_core::AppName
source · pub struct AppName(/* private fields */);
Expand description
Name of the application that is run by end users.
This is usually the crate name of the final binary. It needs to be passed in from the executable crate, as it is not possible for Peace to detect it within the library itself.
Must begin with a letter or underscore, and contain only letters, numbers, and underscores.
§Examples
The following are all examples of valid AppName
s:
let _default = app_name!(); // defaults to calling crate name
let _snake = app_name!("snake_case");
let _camel = app_name!("camelCase");
let _pascal = app_name!("PascalCase");
Implementations§
source§impl AppName
impl AppName
sourcepub fn new(s: &'static str) -> Result<Self, AppNameInvalidFmt<'_>>
pub fn new(s: &'static str) -> Result<Self, AppNameInvalidFmt<'_>>
Returns a new AppName
if the given &str
is valid.
Most users should use the app_name!
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 AppName
impl<'de> Deserialize<'de> for AppName
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 PartialEq for AppName
impl PartialEq for AppName
source§impl Presentable for AppName
impl Presentable for AppName
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 TryFrom<&'static str> for AppName
impl TryFrom<&'static str> for AppName
§type Error = AppNameInvalidFmt<'static>
type Error = AppNameInvalidFmt<'static>
The type returned in the event of a conversion error.
source§impl TryFrom<String> for AppName
impl TryFrom<String> for AppName
§type Error = AppNameInvalidFmt<'static>
type Error = AppNameInvalidFmt<'static>
The type returned in the event of a conversion error.
impl Eq for AppName
impl StructuralPartialEq for AppName
Auto Trait Implementations§
impl RefUnwindSafe for AppName
impl Send for AppName
impl Sync for AppName
impl Unpin for AppName
impl UnwindSafe for AppName
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
Mutably borrows from an owned value. Read more