pub trait CriRef: CriBase {
fn discard(&self) -> Discard;
fn scheme(&self) -> Option<Self::Scheme<'_>>;
fn authority(&self) -> Option<Authority>;
fn format_uri_ref_like(&self, w: &mut impl Write) -> Result { ... }
fn render_uri_ref_like(&self) -> String { ... }
}Expand description
A CRI reference (which may be full or relative)
This interface comes with no error handling, as it assumes that the underlying object is a CRI. When processing a received unchecked CRI, see [AllegedCri] for an example of how to handle that.
Some CriRef implementations may inherently not support a scheme or a host – for example, the
relative CriRef implied by CoAP Location-* options can only ever suppress CRI references with
discard=True and no scheme or host. Such implementations would use the Never (!) type for
Scheme and Host.
Invariants
Building on CriBase, a CriRef has an additional invariant not expressed in its interface:
For users:
- If Discard is not Discard::All, then scheme, host and port are expected to be None.
Required Methods
The type of authority of the CRI reference
This may be absent if the scheme is absent (indicating that the base URI’s authority is left as is).
Provided Methods
fn format_uri_ref_like(&self, w: &mut impl Write) -> Result
fn format_uri_ref_like(&self, w: &mut impl Write) -> Result
Attempt to express the CRI into something that will probably pass for a URI reference.
Two forms of CRI referencees are inexpressible as URI references:
-
discard=0 but path present: These append a path segment (eg. http://example.com/foo + append bar = http://example.com/foo/bar)
In this case, the “→/” character sequence (which is not a valid URI) is produced.