pub struct ServerVariableResolver<'a> { /* private fields */ }Expand description
Resolves server template variables by parsing CLI arguments and applying validation
Implementations§
Source§impl<'a> ServerVariableResolver<'a>
impl<'a> ServerVariableResolver<'a>
Sourcepub const fn new(spec: &'a CachedSpec) -> Self
pub const fn new(spec: &'a CachedSpec) -> Self
Creates a new resolver for the given spec
Sourcepub fn resolve_variables(
&self,
server_var_args: &[String],
) -> Result<HashMap<String, String>, Error>
pub fn resolve_variables( &self, server_var_args: &[String], ) -> Result<HashMap<String, String>, Error>
Parses and validates server variables from CLI arguments
§Arguments
server_var_args- Command line arguments in format “key=value”
§Returns
Ok(HashMap<String, String>)- Resolved server variables ready for URL substitutionErr(Error)- Validation errors or parsing failures
§Errors
Returns errors for:
- Invalid key=value format
- Unknown server variables not defined in
OpenAPIspec - Enum constraint violations
- Missing required variables (when defaults are not available)
Sourcepub fn substitute_url(
&self,
url_template: &str,
variables: &HashMap<String, String>,
) -> Result<String, Error>
pub fn substitute_url( &self, url_template: &str, variables: &HashMap<String, String>, ) -> Result<String, Error>
Substitutes server variables in a URL template
§Arguments
url_template- URL with template variables like<https://{region}.api.com>variables- Resolved variable values fromresolve_variables
§Returns
Ok(String)- URL with all variables substitutedErr(Error)- If template contains variables not in the provided map
§Errors
Returns errors for:
- Unresolved template variables not found in the provided variables map
- Invalid template variable names (malformed or too long)
Auto Trait Implementations§
impl<'a> Freeze for ServerVariableResolver<'a>
impl<'a> RefUnwindSafe for ServerVariableResolver<'a>
impl<'a> Send for ServerVariableResolver<'a>
impl<'a> Sync for ServerVariableResolver<'a>
impl<'a> Unpin for ServerVariableResolver<'a>
impl<'a> UnwindSafe for ServerVariableResolver<'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