pub struct Device { /* private fields */ }Expand description
How a push notification service names one device (§4.1.2, §8.7).
The three values a Contact URI carries so that a proxy can wake this client: which service to
ask, what that service calls this device, and whatever else the service needs in between.
§Why constructing one can fail
A pn-prid is an opaque token minted by somebody else, and RFC 3261 §25.1’s pvalue does not
admit every octet — =, ;, ? and @ among them. A value carrying one of those, pasted into
a URI unchecked, does not produce a rejected registration; it produces a different URI, with
the tail of the token read as another parameter. So the values are checked once, here, and a
caller holding a token that needs octets outside pvalue percent-escapes it — escaped is part
of the grammar and survives Uri round-tripping unchanged.
Implementations§
Source§impl Device
impl Device
Sourcepub fn new(provider: &str, prid: &str) -> Result<Self, BuildError>
pub fn new(provider: &str, prid: &str) -> Result<Self, BuildError>
The service to ask, and the identifier it knows this device by (§4.1.2).
provider is a value from the registry §8.8 creates; prid is the token the service
issued for this device.
Sourcepub fn with_param(self, param: &str) -> Result<Self, BuildError>
pub fn with_param(self, param: &str) -> Result<Self, BuildError>
Add the pn-param the named service needs (§4.1.2).
Optional because it is service-specific: some need nothing beyond the identifier.
Sourcepub fn set_on(&self, uri: &mut Uri)
pub fn set_on(&self, uri: &mut Uri)
Put these parameters on a URI, replacing any already there (§4.1.2).
Replacing rather than appending is not tidiness: RFC 3261 §19.1.1 says “any given
parameter-name MUST NOT appear more than once” in a URI, and a duplicate makes the whole
URI unparseable at the far end. A stale pn-prid left beside a fresh one would take the
registration down rather than merely be ignored.