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 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 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl 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
sourceimpl PartialEq<CountryTag> for CountryTag
impl PartialEq<CountryTag> for CountryTag
sourcefn eq(&self, other: &CountryTag) -> bool
fn eq(&self, other: &CountryTag) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &CountryTag) -> bool
fn ne(&self, other: &CountryTag) -> bool
This method tests for !=
.
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>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
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 more
sourceimpl 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 T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more