pub struct DocumentationRegistrant { /* private fields */ }Expand description
Process-wide registry of routes and documentation settings.
Holds the base path, global rate limit, auth settings, group descriptions,
registered routes, global headers, test HTTP clients, and the
DocumentationMode. Starts with base path "/", no rate limit,
Conventional mode, and the three built-in HTTP clients.
Access the shared instance via global,
get_instance, or
get_instance_mut.
Implementations§
Source§impl DocumentationRegistrant
impl DocumentationRegistrant
Sourcepub fn global() -> &'static RwLock<Self>
pub fn global() -> &'static RwLock<Self>
Returns the shared registry, creating it on first use.
Sourcepub fn get_instance() -> RwLockReadGuard<'static, Self>
pub fn get_instance() -> RwLockReadGuard<'static, Self>
Returns a read guard for the shared registry.
Panics if the lock is poisoned.
Sourcepub fn get_instance_mut() -> RwLockWriteGuard<'static, Self>
pub fn get_instance_mut() -> RwLockWriteGuard<'static, Self>
Returns a write guard for the shared registry.
Panics if the lock is poisoned.
Sourcepub fn bind_base(&mut self, base: impl Into<String>)
pub fn bind_base(&mut self, base: impl Into<String>)
Sets the base path used for the generated servers entries.
An empty value resets the base path to "/".
Sourcepub fn bind_base_list(&mut self, roots: &[String])
pub fn bind_base_list(&mut self, roots: &[String])
Sets the base path from a list of roots, using the first entry.
Falls back to "/" when the list is empty.
Sourcepub fn server_paths(&self) -> &[String]
pub fn server_paths(&self) -> &[String]
Returns all configured mount/bind paths used as OpenAPI server paths.
Sourcepub fn set_global_rate_limit(&mut self, limit: Option<u32>)
pub fn set_global_rate_limit(&mut self, limit: Option<u32>)
Sets the global rate limit in requests per minute (None means unlimited).
Sourcepub fn get_global_rate_limit(&self) -> Option<u32>
pub fn get_global_rate_limit(&self) -> Option<u32>
Returns the global rate limit in requests per minute, if set.
Sourcepub fn set_auth_settings(&mut self, m: HashMap<String, String>)
pub fn set_auth_settings(&mut self, m: HashMap<String, String>)
Replaces the authentication settings map used in the spec description and security schemes.
Sourcepub fn get_auth_settings(&self) -> &HashMap<String, String>
pub fn get_auth_settings(&self) -> &HashMap<String, String>
Returns the authentication settings map.
Sourcepub fn set_global_headers(&mut self, headers: HashMap<String, String>)
pub fn set_global_headers(&mut self, headers: HashMap<String, String>)
Sets the legacy shared global headers bucket.
Sourcepub fn set_global_headers_scoped(
&mut self,
headers: HashMap<String, String>,
authenticated_only: bool,
)
pub fn set_global_headers_scoped( &mut self, headers: HashMap<String, String>, authenticated_only: bool, )
Sets scoped global headers: the authenticated bucket when
authenticated_only is true, otherwise the unauthenticated bucket.
Sourcepub fn get_global_headers(&self) -> HashMap<String, String>
pub fn get_global_headers(&self) -> HashMap<String, String>
Returns legacy, unauthenticated, and authenticated headers merged together.
Later buckets overwrite earlier ones on key conflicts.
Sourcepub fn get_authenticated_global_headers(&self) -> HashMap<String, String>
pub fn get_authenticated_global_headers(&self) -> HashMap<String, String>
Returns legacy plus authenticated headers merged together.
Sourcepub fn get_authenticated_only_headers(&self) -> &HashMap<String, String>
pub fn get_authenticated_only_headers(&self) -> &HashMap<String, String>
Returns only headers configured for authenticated requests.
Sourcepub fn get_unauthenticated_global_headers(&self) -> HashMap<String, String>
pub fn get_unauthenticated_global_headers(&self) -> HashMap<String, String>
Returns legacy plus unauthenticated headers merged together.
Sourcepub fn set_documentation_mode(&mut self, mode: DocumentationMode)
pub fn set_documentation_mode(&mut self, mode: DocumentationMode)
Sets the DocumentationMode controlling docs visibility in production.
Sourcepub fn get_documentation_mode(&self) -> DocumentationMode
pub fn get_documentation_mode(&self) -> DocumentationMode
Returns the current DocumentationMode.
Sourcepub fn register_http_client(&mut self, client: Arc<dyn DocHttpClient>)
pub fn register_http_client(&mut self, client: Arc<dyn DocHttpClient>)
Adds an extra DocHttpClient to the test-execution client list.
Sourcepub fn get_http_clients(&self) -> Vec<Arc<dyn DocHttpClient>>
pub fn get_http_clients(&self) -> Vec<Arc<dyn DocHttpClient>>
Returns all registered test-execution HTTP clients.
Sourcepub fn set_group_description(
&mut self,
group: impl Into<String>,
desc: impl Into<String>,
)
pub fn set_group_description( &mut self, group: impl Into<String>, desc: impl Into<String>, )
Sets the description for one documentation group (tag).
Sourcepub fn set_group_descriptions(&mut self, descriptions: HashMap<String, String>)
pub fn set_group_descriptions(&mut self, descriptions: HashMap<String, String>)
Replaces all group descriptions, keeping only entries with a non-empty trimmed name and storing trimmed names and values.
Sourcepub fn get_group_description(&self, group: &str) -> String
pub fn get_group_description(&self, group: &str) -> String
Returns the description for a group, or "N/A" when missing or blank.
Sourcepub fn get_group_descriptions(&self) -> &HashMap<String, String>
pub fn get_group_descriptions(&self) -> &HashMap<String, String>
Returns all group descriptions keyed by group name.
Sourcepub fn register_route(
&mut self,
path: &str,
method: &str,
controller_class: &str,
description: RouteDescription,
)
pub fn register_route( &mut self, path: &str, method: &str, controller_class: &str, description: RouteDescription, )
Records one route with its path, method, controller name, and metadata.
Sourcepub fn get_registered_routes(&self) -> &[RegisteredRoute]
pub fn get_registered_routes(&self) -> &[RegisteredRoute]
Returns all registered routes in registration order.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for DocumentationRegistrant
impl !UnwindSafe for DocumentationRegistrant
impl Freeze for DocumentationRegistrant
impl Send for DocumentationRegistrant
impl Sync for DocumentationRegistrant
impl Unpin for DocumentationRegistrant
impl UnsafeUnpin for DocumentationRegistrant
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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> ⓘ
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> ⓘ
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