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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)