Struct dcsv::ValueLimiter
source · pub struct ValueLimiter { /* private fields */ }Expand description
Limiter that costraints which data that Value can hold
VaulueLimiter has four properties
- type ( Eitehr number or text )
- default value
- variants ( Range of values )
- pattern ( Regex pattern )
Implementations§
source§impl ValueLimiter
impl ValueLimiter
sourcepub fn is_convertible(&self, value: &Value) -> Option<ValueType>
pub fn is_convertible(&self, value: &Value) -> Option<ValueType>
Check if given value can be converted to the type of valuelimiter
sourcepub fn from_line(attributes: &[impl AsRef<str>]) -> DcsvResult<Self>
pub fn from_line(attributes: &[impl AsRef<str>]) -> DcsvResult<Self>
Create value limiter from attributes
The order is
- Type
- Default
- Variant
- Pattern
sourcepub fn get_default(&self) -> Option<&Value>
pub fn get_default(&self) -> Option<&Value>
Get default value from limiter
sourcepub fn get_variant(&self) -> Option<&Vec<Value>>
pub fn get_variant(&self) -> Option<&Vec<Value>>
Return variant reference
sourcepub fn set_variant(
&mut self,
default: Value,
variants: &[Value]
) -> DcsvResult<()>
pub fn set_variant( &mut self, default: Value, variants: &[Value] ) -> DcsvResult<()>
Set variant
sourcepub fn get_pattern(&self) -> Option<&Regex>
pub fn get_pattern(&self) -> Option<&Regex>
Get pattern
sourcepub fn set_pattern(&mut self, default: Value, pattern: Regex) -> DcsvResult<()>
pub fn set_pattern(&mut self, default: Value, pattern: Regex) -> DcsvResult<()>
Set pattern
Trait Implementations§
source§impl Clone for ValueLimiter
impl Clone for ValueLimiter
source§fn clone(&self) -> ValueLimiter
fn clone(&self) -> ValueLimiter
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 moresource§impl Debug for ValueLimiter
impl Debug for ValueLimiter
source§impl Default for ValueLimiter
impl Default for ValueLimiter
source§fn default() -> ValueLimiter
fn default() -> ValueLimiter
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl RefUnwindSafe for ValueLimiter
impl Send for ValueLimiter
impl Sync for ValueLimiter
impl Unpin for ValueLimiter
impl UnwindSafe for ValueLimiter
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