Struct Field

Source
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

Source

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 field
  • field_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);
Source

pub fn name(&self) -> &String

Get the name for this field.

Source

pub fn index(&self) -> usize

Get the index for this field.

Source

pub fn field_type(&self) -> &FieldType

Get the FieldType for this field.

Source

pub fn ignore_blanks(&self) -> bool

Get the ignore blanks setting for this field

Source

pub fn ignore_case(&self) -> bool

Get the ignore case setting for this field.

Source

pub fn random(&self) -> bool

Get the random setting for this field.

Source

pub fn with_name(self, name: String) -> Field

Specify a name for this field

Source

pub fn with_str_name(self, name: &str) -> Field

Specify a name for this field as &str

Source

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.

Source

pub fn with_field_type(self, field_type: FieldType) -> Field

Specify the field type for this field. See FieldType for supported types.

Source

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.

Source

pub fn with_ignore_case(self, ignore_case: bool) -> Field

Specify whether to ignore case for comparison.

Source

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§

Source§

impl Clone for Field

Source§

fn clone(&self) -> Field

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Field

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V