pub fn check_known_capabilities<S: AsRef<str>>(
req: &JmapRequest,
known: &[S],
) -> Result<(), JmapError>Expand description
Validate that every capability URI in req.using is in the known set.
RFC 8620 §3.3 requires the server to return an unknownCapability error
(HTTP 400) if the request declares a capability the server does not support.
This library cannot enforce that check because it has no knowledge of which
capabilities a given deployment supports — that is the caller’s
responsibility.
Call this immediately after parse_request and map any Err to an HTTP
400 response using crate::request_error.
§Errors
Returns JmapError::unknown_capability_with_detail for the first URI in
req.using that is not present in known. If all URIs are known,
returns Ok(()).
§Example
let req = JmapRequest::new(
vec!["urn:ietf:params:jmap:core".into()],
vec![],
None,
);
let known = &["urn:ietf:params:jmap:core", "urn:ietf:params:jmap:mail"];
check_known_capabilities(&req, known).expect("all URIs in known — Ok(()) expected (doctest)");