SpecificEndianOwned

Trait SpecificEndianOwned 

Source
pub trait SpecificEndianOwned
where Self: Clone,
{ type Big; type Little; // Required methods fn to_big_endian(&self) -> Self::Big; fn to_little_endian(&self) -> Self::Little; fn from_big_endian(&self) -> Self::Big; fn from_little_endian(&self) -> Self::Little; // Provided method fn endian(&self) -> Endian { ... } }
Expand description

Endian conversion trait for owned / non-Copy types.

The existing SpecificEndian trait requires Copy because many of this crate’s wrapper APIs (like BigEndian<T>::to_bits() and to_native()) return values by copy.

Text and buffer types (e.g. Vec<_>, String) are not Copy, but we still want to provide endian-aware conversions for them. This trait mirrors the API of SpecificEndian without requiring Copy.

This is intentionally a separate trait to avoid a breaking change to the existing SpecificEndian ecosystem.

Required Associated Types§

Source

type Big

The big-endian form of this type.

Source

type Little

The little-endian form of this type.

Required Methods§

Source

fn to_big_endian(&self) -> Self::Big

Source

fn to_little_endian(&self) -> Self::Little

Source

fn from_big_endian(&self) -> Self::Big

Source

fn from_little_endian(&self) -> Self::Little

Provided Methods§

Source

fn endian(&self) -> Endian

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§

Source§

impl SpecificEndianOwned for Utf16StringBE

Available on crate feature text_utf16 and (crate features text_utf8 or text_utf16 or text_utf32 or text_fixed) only.
Source§

impl SpecificEndianOwned for Utf16StringLE

Available on crate feature text_utf16 and (crate features text_utf8 or text_utf16 or text_utf32 or text_fixed) only.
Source§

impl SpecificEndianOwned for Utf32StringBE

Available on crate feature text_utf32 and (crate features text_utf8 or text_utf16 or text_utf32 or text_fixed) only.
Source§

impl SpecificEndianOwned for Utf32StringLE

Available on crate feature text_utf32 and (crate features text_utf8 or text_utf16 or text_utf32 or text_fixed) only.
Source§

impl<const N: usize> SpecificEndianOwned for FixedUtf16BeCodeUnits<N>

Available on crate feature text_fixed and crate feature text_utf16 and (crate features text_utf8 or text_utf16 or text_utf32 or text_fixed) only.
Source§

impl<const N: usize> SpecificEndianOwned for FixedUtf16LeCodeUnits<N>

Available on crate feature text_fixed and crate feature text_utf16 and (crate features text_utf8 or text_utf16 or text_utf32 or text_fixed) only.
Source§

impl<const N: usize> SpecificEndianOwned for FixedUtf32BeCodeUnits<N>

Available on crate feature text_fixed and crate feature text_utf32 and (crate features text_utf8 or text_utf16 or text_utf32 or text_fixed) only.
Source§

impl<const N: usize> SpecificEndianOwned for FixedUtf32LeCodeUnits<N>

Available on crate feature text_fixed and crate feature text_utf32 and (crate features text_utf8 or text_utf16 or text_utf32 or text_fixed) only.