pub enum MiddlewareConfig {
Named {
name: String,
config: UniversalValue,
},
On {
name: String,
},
Off {
name: String,
},
}Variants§
Implementations§
Source§impl MiddlewareConfig
impl MiddlewareConfig
Sourcepub fn new_named_json(name: String, config: Value) -> Self
pub fn new_named_json(name: String, config: Value) -> Self
Create new named middleware with JSON configuration
Sourcepub fn new_named_yaml(name: String, config: Value) -> Self
pub fn new_named_yaml(name: String, config: Value) -> Self
Create new named middleware with YAML configuration
Sourcepub fn new_on(name: String) -> Self
pub fn new_on(name: String) -> Self
Create new enabled middleware without explicit configuration
Sourcepub fn config_as_json(&self) -> Result<Value>
pub fn config_as_json(&self) -> Result<Value>
Get configuration as JSON Value
Sourcepub fn config_as_yaml(&self) -> Result<Value>
pub fn config_as_yaml(&self) -> Result<Value>
Get configuration as YAML Value
Sourcepub fn config_to_json_string(&self) -> Result<String>
pub fn config_to_json_string(&self) -> Result<String>
Get configuration as JSON string
Sourcepub fn config_to_yaml_string(&self) -> Result<String>
pub fn config_to_yaml_string(&self) -> Result<String>
Get configuration as YAML string
Sourcepub fn config_into<T: for<'de> Deserialize<'de>>(&self) -> Result<T>
pub fn config_into<T: for<'de> Deserialize<'de>>(&self) -> Result<T>
Convert configuration to specific type using serde
Sourcepub fn from_serializable<T: Serialize>(
name: impl Into<String>,
config: T,
) -> Result<Self>
pub fn from_serializable<T: Serialize>( name: impl Into<String>, config: T, ) -> Result<Self>
Create middleware config from any serializable struct (super convenient!)
Usage:
let config = MyConfig { level: "warn".to_string() };
let middleware = MiddlewareConfig::from_serializable("httpward_log_module", config).unwrap();Sourcepub fn from_yaml_str(
name: impl Into<String>,
yaml_str: impl AsRef<str>,
) -> Result<Self>
pub fn from_yaml_str( name: impl Into<String>, yaml_str: impl AsRef<str>, ) -> Result<Self>
Create middleware config from YAML string (1-liner friendly)
Usage:
let middleware = MiddlewareConfig::from_yaml_str("httpward_log_module", "level: warn").unwrap();Sourcepub fn from_json_str(
name: impl Into<String>,
json_str: impl AsRef<str>,
) -> Result<Self>
pub fn from_json_str( name: impl Into<String>, json_str: impl AsRef<str>, ) -> Result<Self>
Create middleware config from JSON string (1-liner friendly)
Usage:
let middleware = MiddlewareConfig::from_json_str("httpward_log_module", r#"{"level": "warn"}"#).unwrap();Sourcepub fn parse_config<T: for<'de> Deserialize<'de>>(&self) -> Result<T>
pub fn parse_config<T: for<'de> Deserialize<'de>>(&self) -> Result<T>
Parse config into specific type with elegant error handling
Usage:
let middleware = MiddlewareConfig::from_json_str("httpward_log_module", r#"{"level": "warn"}"#).unwrap();
let config: MyConfig = middleware.parse_config().unwrap();Trait Implementations§
Source§impl Clone for MiddlewareConfig
impl Clone for MiddlewareConfig
Source§fn clone(&self) -> MiddlewareConfig
fn clone(&self) -> MiddlewareConfig
Returns a duplicate of the value. Read more
1.0.0 · 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 MiddlewareConfig
impl Debug for MiddlewareConfig
Source§impl<'de> Deserialize<'de> for MiddlewareConfig
impl<'de> Deserialize<'de> for MiddlewareConfig
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl JsonSchema for MiddlewareConfig
impl JsonSchema for MiddlewareConfig
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
Whether JSON Schemas generated for this type should be included directly in parent schemas,
rather than being re-used where possible using the
$ref keyword. Read moreAuto Trait Implementations§
impl Freeze for MiddlewareConfig
impl RefUnwindSafe for MiddlewareConfig
impl Send for MiddlewareConfig
impl Sync for MiddlewareConfig
impl Unpin for MiddlewareConfig
impl UnsafeUnpin for MiddlewareConfig
impl UnwindSafe for MiddlewareConfig
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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