pub trait BusHttpExt {
// Required methods
fn path_param<T: FromStr>(&self, name: &str) -> Result<T, String>;
fn query_param<T: FromStr>(&self, name: &str) -> Option<T>;
fn query_param_or<T: FromStr>(&self, name: &str, default: T) -> T;
}Expand description
HTTP-specific convenience methods for Bus.
Import this trait to access path/query parameter extraction directly from the Bus.
§Example
ⓘ
use ranvier_http::BusHttpExt;
use uuid::Uuid;
let id: Uuid = ranvier_core::try_outcome!(bus.path_param("id"), "path");
let page: i64 = bus.query_param_or("page", 1);Required Methods§
Sourcefn path_param<T: FromStr>(&self, name: &str) -> Result<T, String>
fn path_param<T: FromStr>(&self, name: &str) -> Result<T, String>
Extract and parse a path parameter from the Bus.
Looks up PathParams in the Bus, then parses the named parameter as T.
Returns Err if:
PathParamsis not in the Bus- The named key does not exist in PathParams
- The value cannot be parsed as
T
§Example
ⓘ
use ranvier_http::BusHttpExt;
use uuid::Uuid;
// Inside a transition:
let id: Uuid = ranvier_core::try_outcome!(bus.path_param("id"), "path");Sourcefn query_param<T: FromStr>(&self, name: &str) -> Option<T>
fn query_param<T: FromStr>(&self, name: &str) -> Option<T>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.