[−][src]Struct fixed_width::Field
Defines a field in a fixed width record. There can be 1 or more fields in a fixed width record.
Fields
name: Option<String>
Name of the field.
range: Range<usize>
Byte range of the field.
pad_with: char
The character to use for padding the field.
justify: Justify
The justification (Left or Right) of the field.
Methods
impl Field
[src]
pub fn width(&self) -> usize
[src]
Sets the width of this field in bytes, as specified by the range (start - end).
Example
use fixed_width::Field; let field = Field::default().range(0..5); assert_eq!(field.width(), 5);
pub fn name<T: Into<String>>(self, val: Option<T>) -> Self
[src]
Sets the name of this field. Mainly used when deserializing into a HashMap to derive the keys.
Example
use fixed_width::Field; let field = Field::default().name(Some("thing")); assert_eq!(field.name, Some("thing".to_string()));
pub fn range(self, val: Range<usize>) -> Self
[src]
Sets the range in bytes of this field. The start value represents the first byte of the field, and the end represents the last byte + 1 because this is an exclusive Range.
Example
use fixed_width::Field; let field = Field::default().range(0..4); assert_eq!(field.range, 0..4);
pub fn pad_with(self, val: char) -> Self
[src]
Sets the character to use as padding the value of this field to its byte width.
Example
use fixed_width::Field; let field = Field::default().pad_with('a'); assert_eq!(field.pad_with, 'a');
pub fn justify<T: Into<Justify>>(self, val: T) -> Self
[src]
Sets the justification to use for this field. Left will align to the left and Right to the right.
Example
use fixed_width::{Field, Justify}; let field = Field::default().justify(Justify::Right); assert_eq!(field.justify, Justify::Right);
Trait Implementations
impl Default for Field
[src]
impl Clone for Field
[src]
fn clone(&self) -> Field
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Debug for Field
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,