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 format_spec() -> &'static str;
// Provided methods
fn parse_with_variant(
value: &str,
_variant: Option<&str>,
_field_tag: Option<&str>,
) -> Result<Self>
where Self: Sized { ... }
fn valid_variants() -> Option<Vec<&'static str>> { ... }
}
Expand description
Core trait for all Swift field types
Required Methods§
Sourcefn parse(value: &str) -> Result<Self>where
Self: Sized,
fn parse(value: &str) -> Result<Self>where
Self: Sized,
Parse field value from string representation
Sourcefn to_swift_string(&self) -> String
fn to_swift_string(&self) -> String
Convert field back to SWIFT string format
Sourcefn format_spec() -> &'static str
fn format_spec() -> &'static str
Get field format specification
Provided Methods§
Sourcefn parse_with_variant(
value: &str,
_variant: Option<&str>,
_field_tag: Option<&str>,
) -> Result<Self>where
Self: Sized,
fn parse_with_variant(
value: &str,
_variant: Option<&str>,
_field_tag: Option<&str>,
) -> Result<Self>where
Self: Sized,
Parse field value with variant hint for enum fields Default implementation falls back to regular parse
Sourcefn valid_variants() -> Option<Vec<&'static str>>
fn valid_variants() -> Option<Vec<&'static str>>
Get valid variant letters for enum fields Returns None for non-enum fields, Some(vec) for enum fields
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.