pub struct InstanceId(/* private fields */);Expand description
A device identity that outlives a reboot, a re-address and a change of network (§4.1).
§4.1 requires the value to be “persistent”, which is the whole point: the registrar uses it to recognise that a new registration replaces an old one for the same device rather than adding a second contact for it. A UA that mints a fresh instance on every start accumulates dead bindings at the registrar and looks, to it, like a growing crowd of identical phones.
§4.1 says a UA “SHOULD” use a UUID URN (RFC 4122), which is what InstanceId::generate
makes — but the type accepts any URN, because §4.1 permits other schemes and a UA that
persisted one has to be able to present it again.
Implementations§
Source§impl InstanceId
impl InstanceId
Sourcepub fn generate() -> Self
pub fn generate() -> Self
A fresh random UUID URN (§4.1, RFC 4122 §4.4 — version 4).
Generate this once and store it. Calling it on every start satisfies the syntax and defeats the mechanism.
Sourcepub fn parse(value: &str) -> Option<Self>
pub fn parse(value: &str) -> Option<Self>
Adopt an instance ID a UA persisted earlier.
Rejects anything that is not a URN: §4.1’s grammar is instance-val = urn, and a value
that is not one would be quoted into the Contact and rejected by the registrar rather
than by us.
Sourcepub fn contact_param(&self) -> String
pub fn contact_param(&self) -> String
The Contact header parameter, quoted and bracketed as §4.1’s grammar requires:
+sip.instance="<urn:uuid:…>".
The angle brackets are inside the quotes. Both are load-bearing — the URN contains colons, which would otherwise terminate the parameter value.
Trait Implementations§
Source§impl Clone for InstanceId
impl Clone for InstanceId
Source§fn clone(&self) -> InstanceId
fn clone(&self) -> InstanceId
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for InstanceId
impl Debug for InstanceId
Source§impl PartialEq for InstanceId
impl PartialEq for InstanceId
Source§fn eq(&self, other: &InstanceId) -> bool
fn eq(&self, other: &InstanceId) -> bool
self and other values to be equal, and is used by ==.impl Eq for InstanceId
impl StructuralPartialEq for InstanceId
Auto Trait Implementations§
impl Freeze for InstanceId
impl RefUnwindSafe for InstanceId
impl Send for InstanceId
impl Sync for InstanceId
impl Unpin for InstanceId
impl UnsafeUnpin for InstanceId
impl UnwindSafe for InstanceId
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more