pub struct UOwnedFrame<S = Validated> { /* private fields */ }Expand description
Owned, serialization-neutral native uProtocol frame.
UOwnedFrame carries Phase 01 frame metadata plus optional owned payload
bytes. It is available only with the owned-frame-transport feature and is
additive to the ordinary UTransport/UMessage compatibility path.
Implementations§
Source§impl UOwnedFrame<Validated>
impl UOwnedFrame<Validated>
Sourcepub fn new(
metadata: UFrameMetadata,
payload: Option<Bytes>,
) -> Result<Self, UFrameMetadataError>
pub fn new( metadata: UFrameMetadata, payload: Option<Bytes>, ) -> Result<Self, UFrameMetadataError>
Creates a frame from metadata and optional payload bytes after validation.
§Errors
Returns an error if metadata validation fails or payload presence does not match metadata payload encoding presence.
Sourcepub fn new_unchecked(
metadata: UFrameMetadata,
payload: Option<Bytes>,
) -> UOwnedFrame<Unvalidated>
pub fn new_unchecked( metadata: UFrameMetadata, payload: Option<Bytes>, ) -> UOwnedFrame<Unvalidated>
Creates a frame without validation.
Sourcepub fn with_payload(
metadata: UFrameMetadata,
payload: impl Into<Bytes>,
) -> Result<Self, UFrameMetadataError>
pub fn with_payload( metadata: UFrameMetadata, payload: impl Into<Bytes>, ) -> Result<Self, UFrameMetadataError>
Creates a payload-bearing frame after validation.
§Errors
Returns an error if metadata validation fails or the metadata has no payload encoding.
Sourcepub fn without_payload(
metadata: UFrameMetadata,
) -> Result<Self, UFrameMetadataError>
pub fn without_payload( metadata: UFrameMetadata, ) -> Result<Self, UFrameMetadataError>
Creates a no-payload frame after validation.
§Errors
Returns an error if metadata validation fails or the metadata still has a payload encoding.
Source§impl UOwnedFrame<Unvalidated>
impl UOwnedFrame<Unvalidated>
Sourcepub fn validate(self) -> Result<UOwnedFrame<Validated>, UFrameMetadataError>
pub fn validate(self) -> Result<UOwnedFrame<Validated>, UFrameMetadataError>
Validates the frame, transitioning it to the Validated state.
This is the only way from Unvalidated to Validated; the
state transition IS the validation, and every transport API
accepts only the validated state.
§Errors
Returns an error if metadata is invalid, if payload bytes are present without encoding metadata, or if encoding metadata is present without payload bytes.
Source§impl UOwnedFrame<Validated>
impl UOwnedFrame<Validated>
Sourcepub fn to_umessage(&self) -> Result<UMessage, UFrameMetadataError>
pub fn to_umessage(&self) -> Result<UMessage, UFrameMetadataError>
Projects this frame into a UMessage — the compatibility bridge back
to the UTransport family.
§Errors
Returns an error if the frame metadata cannot be represented as message attributes.
Source§impl<S> UOwnedFrame<S>
impl<S> UOwnedFrame<S>
Sourcepub fn metadata(&self) -> &UFrameMetadata
pub fn metadata(&self) -> &UFrameMetadata
Returns the frame metadata.
Sourcepub fn payload(&self) -> Option<&Bytes>
pub fn payload(&self) -> Option<&Bytes>
Returns the payload bytes when the frame carries a payload.
Sourcepub fn payload_bytes(&self) -> &[u8] ⓘ
pub fn payload_bytes(&self) -> &[u8] ⓘ
Returns the payload bytes, or an empty slice when payload is absent.
Use Self::payload when distinguishing absent payload from present
empty payload matters.
Sourcepub fn has_payload(&self) -> bool
pub fn has_payload(&self) -> bool
Returns whether the frame carries payload bytes, including present empty payloads.
Sourcepub fn into_metadata(self) -> UFrameMetadata
pub fn into_metadata(self) -> UFrameMetadata
Consumes the frame and returns its metadata.
Sourcepub fn into_payload(self) -> Option<Bytes>
pub fn into_payload(self) -> Option<Bytes>
Consumes the frame and returns its optional payload bytes.
Sourcepub fn into_parts(self) -> (UFrameMetadata, Option<Bytes>)
pub fn into_parts(self) -> (UFrameMetadata, Option<Bytes>)
Consumes the frame and returns metadata plus optional payload bytes.
Trait Implementations§
Source§impl<S: Clone> Clone for UOwnedFrame<S>
impl<S: Clone> Clone for UOwnedFrame<S>
Source§fn clone(&self) -> UOwnedFrame<S>
fn clone(&self) -> UOwnedFrame<S>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<S: Debug> Debug for UOwnedFrame<S>
impl<S: Debug> Debug for UOwnedFrame<S>
Source§impl<S: PartialEq> PartialEq for UOwnedFrame<S>
impl<S: PartialEq> PartialEq for UOwnedFrame<S>
Source§impl UFrameView for UOwnedFrame
impl UFrameView for UOwnedFrame
Source§type PayloadReader<'a> = Cursor<&'a [u8]>
where
Self: 'a
type PayloadReader<'a> = Cursor<&'a [u8]> where Self: 'a
Source§type PayloadSlices<'a> = IntoIter<&'a [u8]>
where
Self: 'a
type PayloadSlices<'a> = IntoIter<&'a [u8]> where Self: 'a
Source§fn metadata(&self) -> &UFrameMetadata
fn metadata(&self) -> &UFrameMetadata
Source§fn payload_len(&self) -> usize
fn payload_len(&self) -> usize
Source§fn has_payload(&self) -> bool
fn has_payload(&self) -> bool
Source§fn payload_reader(&self) -> Self::PayloadReader<'_>
fn payload_reader(&self) -> Self::PayloadReader<'_>
Source§fn payload_slices(&self) -> Self::PayloadSlices<'_>
fn payload_slices(&self) -> Self::PayloadSlices<'_>
Source§fn try_contiguous_payload(&self) -> Option<&[u8]>
fn try_contiguous_payload(&self) -> Option<&[u8]>
Source§fn decode_payload_from_reader_as<C, T>(&self) -> Result<T, UWireError>where
C: PayloadCodec + ReadDecodePayload<T>,
fn decode_payload_from_reader_as<C, T>(&self) -> Result<T, UWireError>where
C: PayloadCodec + ReadDecodePayload<T>,
C. Read more