pub struct Utf16BE;Expand description
UTF-16 Big Endian encoding for strings.
Normally, used with StaticString and DynamicString.
§Examples
use rsomeip_bytes::{StaticString, Utf16BE, Serialize as _, Deserialize as _};
// A `StaticString` can be used to always write the same amount of data regardless
// of the size of the string.
let value = String::from("rsomeip");
let string = StaticString::<18, Utf16BE, _>::from(&value);
// Buffer can be any type that implements `BufMut`.
let mut buffer = [0_u8; 18];
// Serialized data includes Byte Order Mark and Delimiter.
assert_eq!(Ok(18), string.serialize(&mut buffer.as_mut_slice()));
assert_eq!(buffer, [
0xfe, 0xff, // UTF-16BE BOM
0, 0x72, 0, 0x73, 0, 0x6f, 0, 0x6d, 0, 0x65, 0, 0x69, 0, 0x70, // "rsomeip"
0x00, 0x00 // Delimiter
]);
// Deserialization automatically strips the BOM and Delimiter.
let output = StaticString::<18, Utf16BE, String>::deserialize(&mut buffer.as_slice())?;
assert_eq!(output, value);Trait Implementations§
impl Copy for Utf16BE
Source§impl Encoding for Utf16BE
impl Encoding for Utf16BE
Source§fn serialize<Value, Buffer>(
value: Value,
buffer: &mut Buffer,
) -> Result<usize, SerializeError>
fn serialize<Value, Buffer>( value: Value, buffer: &mut Buffer, ) -> Result<usize, SerializeError>
Source§fn size<Value>(value: &Value) -> Option<usize>
fn size<Value>(value: &Value) -> Option<usize>
Returns the size of the
value when serialized. Read moreSource§fn deserialize<Buffer>(buffer: &mut Buffer) -> Result<String, DeserializeError>
fn deserialize<Buffer>(buffer: &mut Buffer) -> Result<String, DeserializeError>
impl Eq for Utf16BE
impl StructuralPartialEq for Utf16BE
Auto Trait Implementations§
impl Freeze for Utf16BE
impl RefUnwindSafe for Utf16BE
impl Send for Utf16BE
impl Sync for Utf16BE
impl Unpin for Utf16BE
impl UnsafeUnpin for Utf16BE
impl UnwindSafe for Utf16BE
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more