pub struct SchemaRegistry { /* private fields */ }Available on crate feature
schema only.Expand description
Registry of endpoint schemas.
Implementations§
Source§impl SchemaRegistry
impl SchemaRegistry
Sourcepub fn strict(self, strict: bool) -> Self
pub fn strict(self, strict: bool) -> Self
When true, Self::ensure_route rejects unregistered paths at request time.
Sourcepub fn register_endpoint(
&mut self,
path: impl Into<String>,
method: Method,
request_schema: Option<RootSchema>,
response_schema: Option<RootSchema>,
)
pub fn register_endpoint( &mut self, path: impl Into<String>, method: Method, request_schema: Option<RootSchema>, response_schema: Option<RootSchema>, )
Registers path, method, and optional request/response JSON schemas.
Sourcepub fn register_full(
&mut self,
path: impl Into<String>,
method: Method,
request_schema: Option<RootSchema>,
response_schema: Option<RootSchema>,
query_schema: Option<RootSchema>,
params_schema: Option<RootSchema>,
)
pub fn register_full( &mut self, path: impl Into<String>, method: Method, request_schema: Option<RootSchema>, response_schema: Option<RootSchema>, query_schema: Option<RootSchema>, params_schema: Option<RootSchema>, )
Registers a route with request, response, query, and params schemas.
Sourcepub fn register_typed<E, Req, Res>(&mut self)where
E: Endpoint,
Req: JsonSchema + 'static,
Res: JsonSchema + 'static,
E::Params: JsonSchema,
E::Query: JsonSchema,
pub fn register_typed<E, Req, Res>(&mut self)where
E: Endpoint,
Req: JsonSchema + 'static,
Res: JsonSchema + 'static,
E::Params: JsonSchema,
E::Query: JsonSchema,
Registers schemas derived from Endpoint and JsonSchema types.
Sourcepub fn ensure_route(&self, path: &str, method: &Method) -> Result<()>
pub fn ensure_route(&self, path: &str, method: &Method) -> Result<()>
Returns an error if strict mode is enabled and the route is not registered.
Sourcepub fn entries(&self) -> &[EndpointSchema]
pub fn entries(&self) -> &[EndpointSchema]
Returns all registered endpoint metadata.
Sourcepub fn request_schema(&self, path: &str, method: &Method) -> Option<&RootSchema>
pub fn request_schema(&self, path: &str, method: &Method) -> Option<&RootSchema>
Returns the request body schema for a route, if registered.
Sourcepub fn response_schema(
&self,
path: &str,
method: &Method,
) -> Option<&RootSchema>
pub fn response_schema( &self, path: &str, method: &Method, ) -> Option<&RootSchema>
Returns the response body schema for a route, if registered.
Sourcepub fn query_schema(&self, path: &str, method: &Method) -> Option<&RootSchema>
pub fn query_schema(&self, path: &str, method: &Method) -> Option<&RootSchema>
Returns the query string schema for a route, if registered.
Sourcepub fn params_schema(&self, path: &str, method: &Method) -> Option<&RootSchema>
pub fn params_schema(&self, path: &str, method: &Method) -> Option<&RootSchema>
Returns the path-parameter schema for a route, if registered.
Trait Implementations§
Source§impl Clone for SchemaRegistry
impl Clone for SchemaRegistry
Source§fn clone(&self) -> SchemaRegistry
fn clone(&self) -> SchemaRegistry
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SchemaRegistry
impl Debug for SchemaRegistry
Auto Trait Implementations§
impl Freeze for SchemaRegistry
impl RefUnwindSafe for SchemaRegistry
impl Send for SchemaRegistry
impl Sync for SchemaRegistry
impl Unpin for SchemaRegistry
impl UnsafeUnpin for SchemaRegistry
impl UnwindSafe for SchemaRegistry
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