pub enum ConfigOption {
String(String),
Blob(Vec<u8>),
}Expand description
Represents a configuration value stored in the system.
§Variants
String: Stores the configuration as a string.Blob: Stores the configuration as a binary blob.
§Example
use server::config::ConfigOption;
let config_str = ConfigOption::String("example".to_string());
let config_blob = ConfigOption::Blob(vec![1, 2, 3, 4]);You can also convert String and Vec<u8> directly into ConfigOption
using the From trait:
use server::config::ConfigOption;
let config: ConfigOption = "example".to_string().into();
let blob: ConfigOption = vec![1, 2, 3, 4].into();Variants§
Trait Implementations§
Source§impl AsRef<[u8]> for ConfigOption
Convert ConfigOption into a &[u8] reference when the variant is a Blob.
impl AsRef<[u8]> for ConfigOption
Convert ConfigOption into a &[u8] reference when the variant is a Blob.
§Example
use server::config::ConfigOption;
let config = ConfigOption::Blob(vec![1, 2, 3]);
let byte_ref: &[u8] = config.as_ref(); // WorksSource§impl Clone for ConfigOption
impl Clone for ConfigOption
Source§fn clone(&self) -> ConfigOption
fn clone(&self) -> ConfigOption
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 ConfigOption
impl Debug for ConfigOption
Source§impl Display for ConfigOption
impl Display for ConfigOption
Source§impl From<&str> for ConfigOption
Allows for the conversion from a &str to ConfigOption.
impl From<&str> for ConfigOption
Allows for the conversion from a &str to ConfigOption.
This is useful for passing string literals or string slices directly as ConfigOption.
The conversion will wrap the &str in the ConfigOption::String variant.
§Example
use server::config::ConfigOption;
let config_option: ConfigOption = "example text".into();
assert_eq!(config_option, ConfigOption::String("example text".to_string()));Source§impl From<String> for ConfigOption
impl From<String> for ConfigOption
Source§impl PartialEq for ConfigOption
impl PartialEq for ConfigOption
impl StructuralPartialEq for ConfigOption
Auto Trait Implementations§
impl Freeze for ConfigOption
impl RefUnwindSafe for ConfigOption
impl Send for ConfigOption
impl Sync for ConfigOption
impl Unpin for ConfigOption
impl UnsafeUnpin for ConfigOption
impl UnwindSafe for ConfigOption
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,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> ToHex for T
impl<T> ToHex for T
Source§fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
Encode the hex strict representing
self into the result. Lower case
letters are used (e.g. f9b4ca)Source§fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
Encode the hex strict representing
self into the result. Upper case
letters are used (e.g. F9B4CA)