pub struct RegionCode(/* private fields */);Expand description
A 2-byte region identifier.
let sjc: RegionCode = "SJC".parse().unwrap();
assert_eq!(sjc.to_bytes(), [0x78, 0x53]);
assert_eq!(sjc.to_string(), "SJC");
let valley: RegionCode = "Rogue Valley".parse().unwrap();
assert_eq!(valley.to_string(), "0xDF6F");Implementations§
Source§impl RegionCode
impl RegionCode
Sourcepub const fn from_bytes(bytes: [u8; 2]) -> Self
pub const fn from_bytes(bytes: [u8; 2]) -> Self
Wrap a code from its two wire bytes.
Sourcepub fn from_iata(code: &str) -> Result<Self, RegionCodeError>
pub fn from_iata(code: &str) -> Result<Self, RegionCodeError>
Encode a 3-letter IATA airport code.
Case-insensitive. Anything that is not exactly three ASCII letters is rejected, so that named regions cannot be mistaken for airports.
Trait Implementations§
Source§impl Clone for RegionCode
impl Clone for RegionCode
Source§fn clone(&self) -> RegionCode
fn clone(&self) -> RegionCode
Returns a duplicate of the value. Read more
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for RegionCode
impl Debug for RegionCode
Source§impl Display for RegionCode
impl Display for RegionCode
Source§impl From<RegionCode> for [u8; 2]
impl From<RegionCode> for [u8; 2]
Source§fn from(code: RegionCode) -> Self
fn from(code: RegionCode) -> Self
Converts to this type from the input type.
Source§impl FromStr for RegionCode
Parse a region code from its textual form.
impl FromStr for RegionCode
Parse a region code from its textual form.
Three ASCII letters are an IATA code, 0xXXXX is a raw code, and
anything else is a region name.
Source§impl Hash for RegionCode
impl Hash for RegionCode
Source§impl Ord for RegionCode
impl Ord for RegionCode
Source§impl PartialEq for RegionCode
impl PartialEq for RegionCode
Source§impl PartialOrd for RegionCode
impl PartialOrd for RegionCode
impl Copy for RegionCode
impl Eq for RegionCode
impl StructuralPartialEq for RegionCode
Auto Trait Implementations§
impl Freeze for RegionCode
impl RefUnwindSafe for RegionCode
impl Send for RegionCode
impl Sync for RegionCode
impl Unpin for RegionCode
impl UnwindSafe for RegionCode
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)