#[non_exhaustive]pub struct Id(/* private fields */);Expand description
Opaque non-empty server-assigned identifier (RFC 8620 §1.2).
Character set: URL-safe base64 alphabet (A-Za-z0-9, -, _), max 255 octets.
Clients MUST treat Id values as opaque strings — no parsing of structure.
§Deserialization is validated
Deserializing an Id applies the same check as Id::new_validated,
so a wire value outside the RFC 8620 §1.2 syntax is a deserialization
error rather than an unchecked Id:
use jmap_types::Id;
assert!(serde_json::from_str::<Id>("\"abc-_123\"").is_ok());
assert!(serde_json::from_str::<Id>("\"has space\"").is_err());Id::from remains an unchecked constructor for values the caller
already trusts.
Implementations§
Source§impl Id
impl Id
Sourcepub fn into_inner(self) -> String
pub fn into_inner(self) -> String
Consumes the value and returns the inner String.
Source§impl Id
impl Id
Sourcepub fn new_validated(s: impl Into<String>) -> Result<Self, ValidationError>
pub fn new_validated(s: impl Into<String>) -> Result<Self, ValidationError>
Construct an Id with RFC 8620 §1.2 syntax validation.
RFC 8620 §1.2 restricts Ids to the URL-safe base64 alphabet defined
in RFC 4648 §5, excluding the pad character =. The permitted
characters are therefore the ASCII alphanumerics (A-Z, a-z,
0-9), hyphen (-), and underscore (_). The string must also
be non-empty and at most 255 bytes.
§Errors
Returns ValidationError when the input does not satisfy
RFC 8620 §1.2. The error description contains a category keyword
that callers can match on if they need finer-grained handling:
"empty"— the input was an empty string;"exceeds 255 bytes"— the input was longer than the spec maximum;"invalid character"— the input contained at least one character outsideA-Z,a-z,0-9,-,_.
Use Id::from when the value is known to be valid (e.g. a string
received from a JMAP server response).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Id
impl<'de> Deserialize<'de> for Id
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
impl Eq for Id
Source§impl Ord for Id
impl Ord for Id
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for Id
impl PartialOrd for Id
impl StructuralPartialEq for Id
Auto Trait Implementations§
impl Forget for Id
impl Freeze for Id
impl Move for Id
impl RefUnwindSafe for Id
impl Send for Id
impl Sync for Id
impl Unpin for Id
impl UnsafeUnpin 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.