Struct eu4save::CountryTag
source · [−]pub struct CountryTag(_);
Expand description
Wrapper around a Country’s unique three byte tag
use eu4save::CountryTag;
let tag: CountryTag = "ENG".parse()?;
assert_eq!(tag.to_string(), String::from("ENG"));
Implementations
sourceimpl CountryTag
impl CountryTag
sourcepub fn create<T: AsRef<[u8]>>(s: T) -> Result<Self, Eu4Error>
pub fn create<T: AsRef<[u8]>>(s: T) -> Result<Self, Eu4Error>
Create a country tag from a byte slice. Returns error if input is not three bytes in length and not compose of dashes or alphanumeric data.
use eu4save::CountryTag;
let tag: CountryTag = CountryTag::create(b"ENG")?;
sourcepub fn is<T: AsRef<[u8]>>(&self, s: T) -> bool
pub fn is<T: AsRef<[u8]>>(&self, s: T) -> bool
An ergonomic shortcut to determine if input byte slice contains the same data as the tag
use eu4save::CountryTag;
let tag: CountryTag = CountryTag::create(b"ENG")?;
assert!(tag.is(b"ENG"));
Trait Implementations
sourceimpl AsRef<str> for CountryTag
impl AsRef<str> for CountryTag
sourceimpl Clone for CountryTag
impl Clone for CountryTag
sourcefn clone(&self) -> CountryTag
fn clone(&self) -> CountryTag
Returns a copy of the value. Read more
1.0.0 · sourceconst fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresourceimpl Debug for CountryTag
impl Debug for CountryTag
sourceimpl<'de> Deserialize<'de> for CountryTag
impl<'de> Deserialize<'de> for CountryTag
sourcefn 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
sourceimpl Display for CountryTag
impl Display for CountryTag
sourceimpl FromStr for CountryTag
impl FromStr for CountryTag
sourceimpl Hash for CountryTag
impl Hash for CountryTag
sourceimpl Ord for CountryTag
impl Ord for CountryTag
sourcefn cmp(&self, other: &CountryTag) -> Ordering
fn cmp(&self, other: &CountryTag) -> Ordering
1.21.0 · sourceconst fn max(self, other: Self) -> Selfwhere
Self: Sized,
const fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 · sourceconst fn min(self, other: Self) -> Selfwhere
Self: Sized,
const fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
1.50.0 · sourceconst fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
const fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl PartialEq<CountryTag> for CountryTag
impl PartialEq<CountryTag> for CountryTag
sourcefn eq(&self, other: &CountryTag) -> bool
fn eq(&self, other: &CountryTag) -> bool
sourceimpl PartialOrd<CountryTag> for CountryTag
impl PartialOrd<CountryTag> for CountryTag
sourcefn partial_cmp(&self, other: &CountryTag) -> Option<Ordering>
fn partial_cmp(&self, other: &CountryTag) -> Option<Ordering>
1.0.0 · sourceconst fn le(&self, other: &Rhs) -> bool
const fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresourceimpl Serialize for CountryTag
impl Serialize for CountryTag
impl Copy for CountryTag
impl Eq for CountryTag
impl StructuralEq for CountryTag
impl StructuralPartialEq for CountryTag
Auto Trait Implementations
impl RefUnwindSafe for CountryTag
impl Send for CountryTag
impl Sync for CountryTag
impl Unpin for CountryTag
impl UnwindSafe for CountryTag
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more