pub struct AttributeSchema { /* private fields */ }Expand description
Defines the expected attributes for a command handler
Implementations§
Source§impl AttributeSchema
impl AttributeSchema
Sourcepub fn add_required(&mut self, name: &str, description: &str) -> &mut Self
pub fn add_required(&mut self, name: &str, description: &str) -> &mut Self
Adds a required attribute
Sourcepub fn add_optional(&mut self, name: &str, description: &str) -> &mut Self
pub fn add_optional(&mut self, name: &str, description: &str) -> &mut Self
Adds an optional attribute
Sourcepub fn add_optional_with_default(
&mut self,
name: &str,
description: &str,
default: AttributeValue,
) -> &mut Self
pub fn add_optional_with_default( &mut self, name: &str, description: &str, default: AttributeValue, ) -> &mut Self
Adds an optional attribute with a default value
Sourcepub fn validate(
&self,
attributes: &HashMap<String, AttributeValue>,
) -> Result<(), CommandError>
pub fn validate( &self, attributes: &HashMap<String, AttributeValue>, ) -> Result<(), CommandError>
Validates a set of attributes against this schema
Sourcepub fn apply_defaults(&self, attributes: &mut HashMap<String, AttributeValue>)
pub fn apply_defaults(&self, attributes: &mut HashMap<String, AttributeValue>)
Applies defaults to a set of attributes
Sourcepub fn defaults(&self) -> &HashMap<String, AttributeValue>
pub fn defaults(&self) -> &HashMap<String, AttributeValue>
Gets the default values
Trait Implementations§
Source§impl Clone for AttributeSchema
impl Clone for AttributeSchema
Source§fn clone(&self) -> AttributeSchema
fn clone(&self) -> AttributeSchema
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 moreAuto Trait Implementations§
impl Freeze for AttributeSchema
impl RefUnwindSafe for AttributeSchema
impl Send for AttributeSchema
impl Sync for AttributeSchema
impl Unpin for AttributeSchema
impl UnwindSafe for AttributeSchema
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