pub struct Field { /* private fields */ }
Expand description
Defines a field in a line record.
The Field definition is eventually used in comparison.
§Examples
// specify that the second field of the record is a String and that its blanks to be stripped
// and case ignored for comparison
use text_file_sort::field::Field;
use text_file_sort::field_type::FieldType;
let field = Field::new(2, FieldType::String)
.with_ignore_blanks(true)
.with_ignore_case(true);
Implementations§
Source§impl Field
impl Field
Sourcepub fn new(index: usize, field_type: FieldType) -> Field
pub fn new(index: usize, field_type: FieldType) -> Field
Create a new Field
§Arguments
index
- the index of the field, starting at 1. Index of 0 treats the complete line as a fieldfield_type
- the type of the field. See FieldType for supported types
§Examples
use text_file_sort::field::Field;
use text_file_sort::field_type::FieldType;
let field = Field::new(1, FieldType::Integer);
Sourcepub fn field_type(&self) -> &FieldType
pub fn field_type(&self) -> &FieldType
Get the FieldType for this field.
Sourcepub fn ignore_blanks(&self) -> bool
pub fn ignore_blanks(&self) -> bool
Get the ignore blanks setting for this field
Sourcepub fn ignore_case(&self) -> bool
pub fn ignore_case(&self) -> bool
Get the ignore case setting for this field.
Sourcepub fn with_str_name(self, name: &str) -> Field
pub fn with_str_name(self, name: &str) -> Field
Specify a name for this field as &str
Sourcepub fn with_index(self, index: usize) -> Field
pub fn with_index(self, index: usize) -> Field
Specify the index for this field starting at 1. Specifying index of 0 treats the complete line as a field.
Sourcepub fn with_field_type(self, field_type: FieldType) -> Field
pub fn with_field_type(self, field_type: FieldType) -> Field
Specify the field type for this field. See FieldType for supported types.
Sourcepub fn with_ignore_blanks(self, ignore_blanks: bool) -> Field
pub fn with_ignore_blanks(self, ignore_blanks: bool) -> Field
Specify whether to ignore blanks for comparison. When true the field will be trimmed before comparison.
Sourcepub fn with_ignore_case(self, ignore_case: bool) -> Field
pub fn with_ignore_case(self, ignore_case: bool) -> Field
Specify whether to ignore case for comparison.
Sourcepub fn with_random(self, random: bool) -> Field
pub fn with_random(self, random: bool) -> Field
Specify whether to generate a random field value. Specifying true will cause the file to be randomly shuffled.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Field
impl RefUnwindSafe for Field
impl Send for Field
impl Sync for Field
impl Unpin for Field
impl UnwindSafe for Field
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