Skip to main content

ArchivedString

Struct ArchivedString 

Source
pub struct ArchivedString { /* private fields */ }
Available on crate feature archive only.
Expand description

The archived form of a UTF-8 string.

Body layout: u32 byte_len followed by UTF-8 bytes. Relative pointers are tied to their address and must not be copied out.

ⓘ
use rustbinary::archive_codec::ArchivedString;
fn relocate(value: &ArchivedString) -> ArchivedString { *value }

Implementations§

Source§

impl ArchivedString

Source

pub unsafe fn as_str_unchecked(&self) -> &str

Resolves the string from the field’s own address.

§Safety

The archive must have been validated with CheckBytes and the backing buffer must be immutable for the returned borrow.

Source

pub fn as_str(&self) -> &str

Returns the string (requires prior CheckBytes).

Source

pub fn as_bytes(&self) -> &[u8] ⓘ

Returns the raw UTF-8 bytes (requires prior CheckBytes).

Source

pub fn len(&self) -> usize

Returns the byte length (requires prior CheckBytes).

Source

pub fn is_empty(&self) -> bool

Whether the string is empty (requires prior CheckBytes).

Trait Implementations§

Source§

impl ArchivedValue for ArchivedString

Source§

impl CheckBytes for ArchivedString

Source§

fn check_at(bytes: &[u8], base: usize) -> Result<(), String>

Validates the archived value at base inside bytes.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.