pub enum Id<'a> {
Null,
Number(u64),
Str(Cow<'a, str>),
}Expand description
Request Id
Variants§
Implementations§
Source§impl<'a> Id<'a>
impl<'a> Id<'a>
Sourcepub fn as_number(&self) -> Option<&u64>
pub fn as_number(&self) -> Option<&u64>
If the Id is a number, returns the associated number. Returns None otherwise.
Sourcepub fn as_str(&self) -> Option<&str>
pub fn as_str(&self) -> Option<&str>
If the Id is a String, returns the associated str. Returns None otherwise.
Sourcepub fn into_owned(self) -> Id<'static>
pub fn into_owned(self) -> Id<'static>
Convert Id<'a> to Id<'static> so that it can be moved across threads.
This can cause an allocation if the id is a string.
Sourcepub fn try_parse_inner_as_number(&self) -> Result<u64, InvalidRequestId>
pub fn try_parse_inner_as_number(&self) -> Result<u64, InvalidRequestId>
Extract the underlying number from the ID.
Trait Implementations§
Source§impl<'de: 'a, 'a> Deserialize<'de> for Id<'a>
impl<'de: 'a, 'a> Deserialize<'de> for Id<'a>
Source§fn 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
Source§impl<'a> Ord for Id<'a>
impl<'a> Ord for Id<'a>
Source§impl<'a> PartialOrd for Id<'a>
impl<'a> PartialOrd for Id<'a>
impl<'a> Eq for Id<'a>
impl<'a> StructuralPartialEq for Id<'a>
Auto Trait Implementations§
impl<'a> Freeze for Id<'a>
impl<'a> RefUnwindSafe for Id<'a>
impl<'a> Send for Id<'a>
impl<'a> Sync for Id<'a>
impl<'a> Unpin for Id<'a>
impl<'a> UnwindSafe for Id<'a>
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