pub struct FixedField { /* private fields */ }
Expand description
Fixed field with spec and value.
Since fixed fields have specific length requirements, a well-known spec::FixedField is required
Implementations§
Source§impl FixedField
impl FixedField
Sourcepub fn new(spec: &'static FixedField, value: &str) -> Result<Self, Error>
pub fn new(spec: &'static FixedField, value: &str) -> Result<Self, Error>
Create a new FixeField using the provided spec and value. let mut ff = FixedField::new(&spec::FF_MAX_PRINT_WIDTH, “999”).unwrap();
§Examples
use sip2::FixedField;
use sip2::spec;
assert!(FixedField::new(&spec::FF_MAX_PRINT_WIDTH, "999").is_ok());
assert!(FixedField::new(&spec::FF_MAX_PRINT_WIDTH, "999999").is_err());
Sourcepub fn spec(&self) -> &'static FixedField
pub fn spec(&self) -> &'static FixedField
Ref to the FixedField spec that defines our structure.
Sourcepub fn value(&self) -> &str
pub fn value(&self) -> &str
Value stored by this fixed field.
The length of the value will match the length defined by the Fixedfield spec.
Sourcepub fn set_value(&mut self, value: &str) -> Result<(), Error>
pub fn set_value(&mut self, value: &str) -> Result<(), Error>
Apply a value to this FixedField.
§Examples
use sip2::FixedField;
use sip2::spec;
let mut ff = FixedField::new(&spec::FF_MAX_PRINT_WIDTH, "999").unwrap();
ff.set_value("000").unwrap();
assert_eq!(ff.value(), "000");
assert!(ff.set_value("too long").is_err());
Trait Implementations§
Source§impl Debug for FixedField
impl Debug for FixedField
Source§impl PartialEq for FixedField
impl PartialEq for FixedField
impl StructuralPartialEq for FixedField
Auto Trait Implementations§
impl Freeze for FixedField
impl RefUnwindSafe for FixedField
impl Send for FixedField
impl Sync for FixedField
impl Unpin for FixedField
impl UnwindSafe for FixedField
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