pub struct Id { /* private fields */ }
Expand description
Structure for keeping data
Implementations§
Source§impl Id
impl Id
Sourcepub fn into_bytes(self) -> Vec<u8> ⓘ
pub fn into_bytes(self) -> Vec<u8> ⓘ
Return a bytes representation of id
use hyperid::HyperId;
let mut hyperid = HyperId::new();
let id = hyperid.get();
println!("{:?}", id.into_bytes());
Sourcepub fn from_bytes(bytes: Vec<u8>) -> Result<Self, ParseIdError>
pub fn from_bytes(bytes: Vec<u8>) -> Result<Self, ParseIdError>
Build Id instance from bytes
use hyperid::{HyperId, Id};
let bytes = vec![0; 17];
let id = Id::from_bytes(bytes).unwrap();
assert_eq!(vec![0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], id.into_bytes());
Sourcepub fn to_url_safe(&self) -> String
Available on crate feature url_safe
only.
pub fn to_url_safe(&self) -> String
url_safe
only.Return an url safe string
use hyperid::HyperId;
let mut hyperid = HyperId::new();
let id = hyperid.get();
println!("{}", id.to_url_safe()); // 3ZAYYJilG7vHTqiUuaQdFg.0
Sourcepub fn from_url_safe(s: String) -> Result<Id, ParseIdError>
Available on crate feature url_safe
only.
pub fn from_url_safe(s: String) -> Result<Id, ParseIdError>
url_safe
only.Return an url safe string
use hyperid::{HyperId, Id};
let mut hyperid = HyperId::new();
let id1 = hyperid.get();
let s = id1.to_url_safe();
let id2 = Id::from_url_safe(s).unwrap();
assert_eq!(id1, id2);
Trait Implementations§
impl Copy for Id
impl Eq for Id
impl StructuralPartialEq for Id
Auto Trait Implementations§
impl Freeze for Id
impl RefUnwindSafe for Id
impl Send for Id
impl Sync for Id
impl Unpin for Id
impl UnwindSafe for Id
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