pub struct JmapUri { /* private fields */ }Expand description
A parsed jmap:<type>:<accountId>:<objectId> URI.
Build one with JmapUri::new or parse one with str::parse;
Display renders it back to the wire string. The URI
arrives in peer-supplied values, so parsing validates every segment.
use jmap_types::JmapUri;
let uri: JmapUri = "jmap:calendarevent:a1:e42".parse().unwrap();
assert_eq!(uri.data_type(), "calendarevent");
assert_eq!(uri.account_id().as_ref(), "a1");
assert_eq!(uri.object_id().as_ref(), "e42");
assert_eq!(uri.to_string(), "jmap:calendarevent:a1:e42");It serializes as its wire string and deserializes by parsing one, so a malformed value fails deserialization. Ordering compares the type, then the account id, then the object id, consistently with equality (the scheme is case-insensitive and not stored).
Implementations§
Source§impl JmapUri
impl JmapUri
Sourcepub fn new(
data_type: impl Into<String>,
account_id: Id,
object_id: Id,
) -> Result<Self, JmapUriError>
pub fn new( data_type: impl Into<String>, account_id: Id, object_id: Id, ) -> Result<Self, JmapUriError>
Build a URI from its parts.
§Errors
Returns JmapUriError when data_type is not lowercase ASCII
alphanumeric or either id fails RFC 8620 §1.2 validation (an
unvalidated Id::from could otherwise smuggle a : into the
rendered URI).
Sourcepub fn account_id(&self) -> &Id
pub fn account_id(&self) -> &Id
The account the object lives on.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for JmapUri
impl<'de> Deserialize<'de> for JmapUri
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 JmapUri
Source§impl Ord for JmapUri
impl Ord for JmapUri
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 JmapUri
impl PartialOrd for JmapUri
impl StructuralPartialEq for JmapUri
Auto Trait Implementations§
impl Forget for JmapUri
impl Freeze for JmapUri
impl Move for JmapUri
impl RefUnwindSafe for JmapUri
impl Send for JmapUri
impl Sync for JmapUri
impl Unpin for JmapUri
impl UnsafeUnpin for JmapUri
impl UnwindSafe for JmapUri
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.