Struct eu4save::CountryTag[][src]

pub struct CountryTag(_);

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

impl CountryTag[src]

pub fn create<T: AsRef<[u8]>>(s: T) -> Result<Self, Eu4Error>[src]

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")?;

pub fn is<T: AsRef<[u8]>>(&self, s: T) -> bool[src]

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"));

pub fn as_bytes(&self) -> &[u8][src]

Returns the country tag as a byte slice

use eu4save::CountryTag;
let tag: CountryTag = CountryTag::create(b"ENG")?;
assert_eq!(tag.as_bytes(), b"ENG");

pub fn as_str(&self) -> &str[src]

Returns the country tag as a string slice

use eu4save::CountryTag;
let tag: CountryTag = CountryTag::create(b"ENG")?;
assert_eq!(tag.as_str(), "ENG");

Trait Implementations

impl AsRef<str> for CountryTag[src]

impl Clone for CountryTag[src]

impl Copy for CountryTag[src]

impl Debug for CountryTag[src]

impl<'de> Deserialize<'de> for CountryTag[src]

impl Display for CountryTag[src]

impl Eq for CountryTag[src]

impl FromStr for CountryTag[src]

type Err = Eu4Error

The associated error which can be returned from parsing.

impl Hash for CountryTag[src]

impl Ord for CountryTag[src]

impl PartialEq<CountryTag> for CountryTag[src]

impl PartialOrd<CountryTag> for CountryTag[src]

impl Serialize for CountryTag[src]

impl StructuralEq for CountryTag[src]

impl StructuralPartialEq for CountryTag[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.