pub trait EdifactDeserialize: Sized {
// Required method
fn edifact_deserialize(
segments: &[Segment<'_>],
) -> Result<Self, EdifactError>;
// Provided method
fn edifact_deserialize_owned(
segments: &[OwnedSegment],
) -> Result<Self, EdifactError> { ... }
}Expand description
Types that can be deserialized from a slice of EDIFACT segments.
Implement manually or derive with #[derive(EdifactDeserialize)] from the
edifact-rs-derive crate.
Required Methods§
Sourcefn edifact_deserialize(segments: &[Segment<'_>]) -> Result<Self, EdifactError>
fn edifact_deserialize(segments: &[Segment<'_>]) -> Result<Self, EdifactError>
Deserialize Self from the provided segment slice.
The slice may contain any number of segments; implementations extract only the ones they care about and ignore the rest.
Provided Methods§
Sourcefn edifact_deserialize_owned(
segments: &[OwnedSegment],
) -> Result<Self, EdifactError>
fn edifact_deserialize_owned( segments: &[OwnedSegment], ) -> Result<Self, EdifactError>
Deserialize Self from a slice of owned EDIFACT segments.
§Default implementation
Converts each crate::OwnedSegment to its borrowed form via
crate::OwnedSegment::as_borrowed and delegates to
edifact_deserialize. This incurs one
Vec<Segment<'_>> allocation per call.
§Override when performance matters
Types generated by #[derive(EdifactDeserialize)] automatically override
this method to work directly on the owned data without the intermediate
allocation. Manual implementations should also override when used in the
high-throughput reader-streaming path
(deserialize_first_from_reader, deserialize_all_from_reader,
deserialize_messages_from_reader) to avoid the per-message allocation.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl<T> EdifactDeserialize for Vec<T>where
T: EdifactDeserialize + EdifactSegmentTag,
Deserializes each segment matching T::matches_segment as an independent
single-segment slice, collecting the results.
impl<T> EdifactDeserialize for Vec<T>where
T: EdifactDeserialize + EdifactSegmentTag,
Deserializes each segment matching T::matches_segment as an independent
single-segment slice, collecting the results.