pub struct RouteRef<'a> { /* private fields */ }Expand description
The route template of one call, and the values of its {parameters} in
template order.
The template is the schema’s own path string, the same one the server
lists in ROUTE_TRANSPORTS, without the mount prefix; for an RPC call it
is the op id (model.Widget.get, procedure.ping) or batch. Without
the cose feature, or without an envelope on the client, a RouteRef
is ignored.
use cratestack_client_rust::RouteRef;
let id = 7.to_string();
let params = [id.as_str()];
let route = RouteRef::new("/widgets/{id}", ¶ms);
assert_eq!(route.template(), "/widgets/{id}");
assert_eq!(route.params(), ["7"]);
assert_eq!(RouteRef::rpc("model.Widget.list").params().len(), 0);Implementations§
Source§impl<'a> RouteRef<'a>
impl<'a> RouteRef<'a>
Sourcepub const fn new(template: &'a str, params: &'a [&'a str]) -> Self
pub const fn new(template: &'a str, params: &'a [&'a str]) -> Self
A REST route: its template and the decoded values of its parameters, in template order.
Sourcepub const fn rpc(op_id: &'a str) -> Self
pub const fn rpc(op_id: &'a str) -> Self
An RPC route: the op id, or "batch". RPC has no path parameters.
pub const fn template(&self) -> &'a str
pub const fn params(&self) -> &'a [&'a str]
Trait Implementations§
impl<'a> Copy for RouteRef<'a>
impl<'a> Eq for RouteRef<'a>
Source§impl<'a> PartialEq for RouteRef<'a>
impl<'a> PartialEq for RouteRef<'a>
impl<'a> StructuralPartialEq for RouteRef<'a>
Auto Trait Implementations§
impl<'a> Freeze for RouteRef<'a>
impl<'a> RefUnwindSafe for RouteRef<'a>
impl<'a> Send for RouteRef<'a>
impl<'a> Sync for RouteRef<'a>
impl<'a> Unpin for RouteRef<'a>
impl<'a> UnsafeUnpin for RouteRef<'a>
impl<'a> UnwindSafe for RouteRef<'a>
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
Mutably borrows from an owned value. Read more
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
Checks if this value is equivalent to the given key. Read more
§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
Compare self to
key and return true if they are equal.impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
§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>
Converts
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>
Converts
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