Trait SwiftField

Source
pub trait SwiftField:
    Serialize
    + for<'de> Deserialize<'de>
    + Clone
    + Debug {
    // Required methods
    fn parse(value: &str) -> Result<Self>
       where Self: Sized;
    fn to_swift_string(&self) -> String;
    fn validate(&self) -> ValidationResult;
    fn format_spec() -> &'static str;
    fn sample() -> Self
       where Self: Sized;
    fn sample_with_config(config: &FieldConfig) -> Self
       where Self: Sized;
}
Expand description

Core trait for all Swift field types

Required Methods§

Source

fn parse(value: &str) -> Result<Self>
where Self: Sized,

Parse field value from string representation

Source

fn to_swift_string(&self) -> String

Convert field back to SWIFT string format

Source

fn validate(&self) -> ValidationResult

Validate field according to SWIFT format rules

Source

fn format_spec() -> &'static str

Get field format specification

Source

fn sample() -> Self
where Self: Sized,

Generate a random sample of this field

Source

fn sample_with_config(config: &FieldConfig) -> Self
where Self: Sized,

Generate a random sample with configuration

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§