pub struct CountryTag(/* private fields */);Expand description
Wrapper around a Country’s unique three byte tag
use hoi4save::CountryTag;
let tag: CountryTag = "ENG".parse()?;
assert_eq!(tag.to_string(), String::from("ENG"));Implementations§
Source§impl CountryTag
impl CountryTag
Sourcepub fn create<T: AsRef<[u8]>>(s: T) -> Result<Self, Hoi4Error>
pub fn create<T: AsRef<[u8]>>(s: T) -> Result<Self, Hoi4Error>
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 hoi4save::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 hoi4save::CountryTag;
let tag: CountryTag = CountryTag::create(b"ENG")?;
assert!(tag.is(b"ENG"));Trait Implementations§
Source§impl AsRef<str> for CountryTag
impl AsRef<str> for CountryTag
Source§impl Clone for CountryTag
impl Clone for CountryTag
Source§fn clone(&self) -> CountryTag
fn clone(&self) -> CountryTag
Returns a duplicate 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 CountryTag
impl Debug for CountryTag
Source§impl<'de> Deserialize<'de> for CountryTag
impl<'de> Deserialize<'de> for CountryTag
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 CountryTag
impl Display for CountryTag
Source§impl FromStr for CountryTag
impl FromStr for CountryTag
Source§impl Hash for CountryTag
impl Hash for CountryTag
Source§impl Ord for CountryTag
impl Ord for CountryTag
Source§fn cmp(&self, other: &CountryTag) -> Ordering
fn cmp(&self, other: &CountryTag) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for CountryTag
impl PartialEq for CountryTag
Source§impl PartialOrd for CountryTag
impl PartialOrd for CountryTag
Source§impl Serialize for CountryTag
impl Serialize for CountryTag
impl Copy for CountryTag
impl Eq for CountryTag
impl StructuralPartialEq for CountryTag
Auto Trait Implementations§
impl Freeze for CountryTag
impl RefUnwindSafe for CountryTag
impl Send for CountryTag
impl Sync for CountryTag
impl Unpin for CountryTag
impl UnwindSafe for CountryTag
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