#[non_exhaustive]pub struct OpaqueRoute {
pub pattern: String,
pub prefix: Option<String>,
pub methods: Vec<String>,
pub reason: OpaqueReason,
pub note: Option<String>,
}Expand description
A route the description cannot express, recorded rather than dropped.
pattern is the router’s own matching syntax, verbatim. It is deliberately
not a PathTemplate: minting a template for a
catch-all would put a claim in paths that the service does not honour —
either about the path, or about a parameter whose value always contains an
unescaped /. A consumer gets something visible, greppable and diffable
instead of a plausible lie.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.pattern: StringThe router’s matching pattern, verbatim.
prefix: Option<String>The literal prefix the pattern is anchored at, if any.
Recorded so that a reader can tell which part of the URL space the route claims without parsing the router’s matching syntax.
methods: Vec<String>The methods served, spelled as they appear on the wire.
reason: OpaqueReasonWhy it cannot be expressed.
note: Option<String>A human-readable note.
Implementations§
Source§impl OpaqueRoute
impl OpaqueRoute
Sourcepub fn new(pattern: impl Into<String>, reason: OpaqueReason) -> Self
pub fn new(pattern: impl Into<String>, reason: OpaqueReason) -> Self
Records a route under pattern that cannot be described.
Sourcepub fn with_prefix(self, prefix: impl Into<String>) -> Self
pub fn with_prefix(self, prefix: impl Into<String>) -> Self
Records the literal prefix the pattern is anchored at.
Sourcepub fn with_methods<I, S>(self, methods: I) -> Self
pub fn with_methods<I, S>(self, methods: I) -> Self
Records the methods served.
Sourcepub fn is_annotated(document: &Document) -> bool
pub fn is_annotated(document: &Document) -> bool
Whether document carries the annotation at all.
True even when the value is malformed, for the reason
Opaque::is_annotated gives.
Sourcepub fn all(document: &Document) -> Result<Vec<Self>, MalformedAnnotation>
pub fn all(document: &Document) -> Result<Vec<Self>, MalformedAnnotation>
Reads every recorded route from a document.
An absent annotation reads as an empty list, since recording nothing is the same claim as recording an empty list.
§Errors
Returns MalformedAnnotation when the annotation is present but
unreadable. A reason this build does not know is not that case — it
round-trips as OpaqueReason::Unrecognized.
Sourcepub fn append_to(
&self,
document: &mut Document,
) -> Result<(), MalformedAnnotation>
pub fn append_to( &self, document: &mut Document, ) -> Result<(), MalformedAnnotation>
Appends this record to a document.
§Errors
Returns MalformedAnnotation when the document already carries an
unreadable list, rather than replacing it. Appending by overwriting
would delete every route someone else recorded — silent loss of exactly
the record this mechanism exists to keep.
§Panics
Panics only if this record cannot be serialized, which the type makes impossible.
Trait Implementations§
Source§impl Clone for OpaqueRoute
impl Clone for OpaqueRoute
Source§impl Debug for OpaqueRoute
impl Debug for OpaqueRoute
Source§impl<'de> Deserialize<'de> for OpaqueRoute
impl<'de> Deserialize<'de> for OpaqueRoute
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for OpaqueRoute
Source§impl PartialEq for OpaqueRoute
impl PartialEq for OpaqueRoute
Source§impl Serialize for OpaqueRoute
impl Serialize for OpaqueRoute
impl StructuralPartialEq for OpaqueRoute
Auto Trait Implementations§
impl Freeze for OpaqueRoute
impl RefUnwindSafe for OpaqueRoute
impl Send for OpaqueRoute
impl Sync for OpaqueRoute
impl Unpin for OpaqueRoute
impl UnsafeUnpin for OpaqueRoute
impl UnwindSafe for OpaqueRoute
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>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.