pub struct SettingsList {
inner: Vec<SettingsFullData>,
}Expand description
A collection of settings that provides convenient query methods
Wraps a vector of SettingsFullData and provides methods to check
setting states across categories.
Fields§
§inner: Vec<SettingsFullData>Implementations§
source§impl SettingsList
impl SettingsList
sourcepub fn new(settings: Vec<SettingsFullData>) -> Self
pub fn new(settings: Vec<SettingsFullData>) -> Self
Creates a new SettingsList from a vector of settings
§Arguments
settings- Vector ofSettingsFullDatato be managed
sourcepub fn any(&self, category: &str) -> bool
pub fn any(&self, category: &str) -> bool
Checks if any setting in the specified category is enabled
A setting is considered enabled if its param value is “1”
§Arguments
category- The category to check for enabled settings
§Returns
Returns true if any setting in the category is enabled, false
otherwise
§Examples
use crate::server::dtos::entities::settings_dto::{SettingsList, SettingsFullData};
let settings = vec![
SettingsFullData {
level: "user".to_string(),
category: "performance".to_string(),
param: "1".to_string(), // enabled
value: "true".to_string(),
},
SettingsFullData {
level: "user".to_string(),
category: "display".to_string(),
param: "0".to_string(), // disabled
value: "false".to_string(),
},
];
let settings_list = SettingsList::new(settings);
assert!(settings_list.any("performance")); // returns true
assert!(!settings_list.any("display")); // returns false
assert!(!settings_list.any("nonexistent")); // returns falseTrait Implementations§
source§impl Clone for SettingsList
impl Clone for SettingsList
source§fn clone(&self) -> SettingsList
fn clone(&self) -> SettingsList
Returns a copy 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 moreAuto Trait Implementations§
impl Freeze for SettingsList
impl RefUnwindSafe for SettingsList
impl Send for SettingsList
impl Sync for SettingsList
impl Unpin for SettingsList
impl UnwindSafe for SettingsList
Blanket Implementations§
§impl<T> AnySync for T
impl<T> AnySync for T
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit)§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 moreCreates a shared type from an unshared type.
§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Returns the layout of the type.