pub struct Rule { /* private fields */ }
Expand description
A Transformer
paired with Applicability
and a priority which can be applied to fields in a
CSV record.
Implementations§
Source§impl Rule
impl Rule
Sourcepub fn for_fields(field_names: &[&str], transformer: Transformers) -> Rule
pub fn for_fields(field_names: &[&str], transformer: Transformers) -> Rule
Construct a new Rule
whoe Transformer
is applicable to one or more CSV record’s fields
referenced by name with the default priority of 0.
§Examples
use csv_sanity::Rule;
use csv_sanity::transformers::*;
let rule = Rule::for_fields(&["First Name", "Last Name"], Transformers::Capitalize(
CapitalizeTransformer::new()
));
Sourcepub fn for_fields_with_priority(
field_names: &[&str],
transformer: Transformers,
priority: isize,
) -> Rule
pub fn for_fields_with_priority( field_names: &[&str], transformer: Transformers, priority: isize, ) -> Rule
Construct a new Rule
whoe Transformer
is applicable to one or more CSV record’s fields
referenced by name with the specified priority.
§Examples
use csv_sanity::Rule;
use csv_sanity::transformers::*;
let rule = Rule::for_fields_with_priority(&["Fist Name", "Last Name"], Transformers::Capitalize(
CapitalizeTransformer::new()
), 10);
Sourcepub fn global(transformer: Transformers) -> Rule
pub fn global(transformer: Transformers) -> Rule
Construct a new Rule
applicable to all of a CSV record’s fields with the default priority
of 0.
§Examples
use csv_sanity::Rule;
use csv_sanity::transformers::*;
let rule = Rule::global(Transformers::Capitalize(
CapitalizeTransformer::new()
));
Sourcepub fn global_with_priority(transformer: Transformers, priority: isize) -> Rule
pub fn global_with_priority(transformer: Transformers, priority: isize) -> Rule
Construct a new Rule
applicable to all of a CSV record’s fields with the specified
priority.
§Examples
use csv_sanity::Rule;
use csv_sanity::transformers::*;
let rule = Rule::global_with_priority(Transformers::Capitalize(
CapitalizeTransformer::new()
), 10);
Sourcepub fn apply(
&self,
field_value: &str,
field_name: &str,
record_n: usize,
) -> TransformResult
pub fn apply( &self, field_value: &str, field_name: &str, record_n: usize, ) -> TransformResult
Apply this rule to a CSV record’s field, returning the resulting TransformResult
.
§Examples
use csv_sanity::Rule;
use csv_sanity::transformers::*;
let field = "JOHN";
let field_name = "First Name";
let rule = Rule::for_fields(&["First Name", "Last Name"], Transformers::Capitalize(
CapitalizeTransformer::new()
));
rule.apply(field, field_name, 1);
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Rule
impl<'de> Deserialize<'de> for Rule
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 Ord for Rule
impl Ord for Rule
Source§impl PartialOrd for Rule
impl PartialOrd for Rule
impl Eq for Rule
impl StructuralPartialEq for Rule
Auto Trait Implementations§
impl !Freeze for Rule
impl !RefUnwindSafe for Rule
impl Send for Rule
impl Sync for Rule
impl Unpin for Rule
impl UnwindSafe for Rule
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§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
)