Enum steamidfx::id::Id [−][src]
https://developer.valvesoftware.com/wiki/SteamID Holds a steam id in various formats.
Example
use std::convert::TryFrom; let steam_id_64 = steamidfx::id::Id64(76561197983318796); let steam_id_3 = steamidfx::id::Id3("U:1:23053068".to_owned()); assert_eq!( steamidfx::id::Id32::try_from(steam_id_3.clone()).unwrap(), steamidfx::id::Id32("STEAM_0:0:11526534".to_owned()) ); assert_eq!( steamidfx::id::Id64::try_from(steam_id_3).unwrap(), steamidfx::id::Id64(76561197983318796) ); assert_eq!( steamidfx::id::Id32::try_from(steam_id_64).unwrap(), steamidfx::id::Id32("STEAM_0:0:11526534".to_owned()) ); // The most preferred way to construct Ids is using the fallible `TryFrom`. // This will make sure that the constructed `ID`s are correct as some of // the fields of it are required to be of some certain ranges of values. use std::str::FromStr; let id_64 = steamidfx::id::Id::from_str("76561197983318796").unwrap(); let id_64_2 = steamidfx::id::Id::try_from(76561197983318796).unwrap(); let id_32 = steamidfx::id::Id::from_str("STEAM_0:0:11526534").unwrap(); let id_3 = steamidfx::id::Id::from_str("U:1:23053068").unwrap(); // This way you'll make sure after unpacking the `Result` that the value is correct // at least, according to the specification.
Variants
Id64(Id64)
Steam ID in a single integer format (SteamID64).
Example: 7656119xxxxxxxxxx
.
Id32(Id32)
Steam ID 32 in the default format, starting with STEAM_0
.
Example: STEAM_0:X:XXXXXXXX
.
Id3(Id3)
Steam ID in the format called “Steam ID 3”.
Example: U:1:xxxxxxxx
.
Implementations
impl Id
[src]
impl Id
[src]pub fn id64(&self) -> Result<Id64>
[src]
Converts (if needed) the current id format into id64.
Errors
Throws crate::error::Error
if it was impossible to extract the steam id 64.
pub fn id32(&self) -> Result<Id32>
[src]
Converts (if needed) the current id format into id32.
Errors
Throws crate::error::Error
if it was impossible to extract the steam id 32.
pub fn into_id64(self) -> Result<Id>
[src]
Consumes the object and converts it into a steam id in the id64 format.
Errors
Throws crate::error::Error
if it was impossible to extract the steam id 64.
pub fn into_id32(self) -> Result<Id>
[src]
Consumes the object and converts it into a steam id in the id32 format.
Errors
Throws crate::error::Error
if it was impossible to extract the steam id 32.
pub fn is_same(&self, other: &Id) -> Result<bool>
[src]
Attempts to compare two ids. Returns true
when they are representing
the same values, even using different formats.
The conventional Eq
and PartialEq
traits derived will be checking
the enum variants and strings inside, which is sometimes not what we want.
Sometimes we just want to say that these two Id
objects represent the
same person, or an entity of valve. For that, we aren’t interested in the
format of the ID, but rather in the data it provides.
Errors
Returns an error when it is impossible to convert both ids to a single
format: id64
. This format is used as it is the most commonly used one,
and provides the most information possible. Hence, all the ID formats
should ideally be convertible to it just fine, but we are still performing
all the checks to be a bit more cautious about it.
Examples
use std::str::FromStr; use std::convert::TryFrom; let id_64 = steamidfx::id::Id::try_from(76561197983318796).unwrap(); let id_32 = steamidfx::id::Id::from_str("STEAM_0:0:11526534").unwrap(); let id_3 = steamidfx::id::Id::from_str("U:1:23053068").unwrap(); assert!(id_3.is_same(&id_32).unwrap()); assert!(id_32.is_same(&id_64).unwrap());
Trait Implementations
impl<'de> Deserialize<'de> for Id
[src]
impl<'de> Deserialize<'de> for Id
[src]fn deserialize<D>(deserializer: D) -> Result<Id, D::Error> where
D: Deserializer<'de>,
[src]
D: Deserializer<'de>,
impl PartialOrd<Id> for Id
[src]
impl PartialOrd<Id> for Id
[src]impl StructuralEq for Id
[src]
impl StructuralEq for Id
[src]impl StructuralPartialEq for Id
[src]
impl StructuralPartialEq for Id
[src]