Skip to main content

Reader

Struct Reader 

Source
pub struct Reader<'a> {
    pub wide_seen: bool,
    /* private fields */
}
Expand description

A reader of a resource’s fields, little-endian, that knows the block structure.

Fields§

§wide_seen: bool

A UTF-16 System::String was read (older builds write every string that way).

Implementations§

Source§

impl<'a> Reader<'a>

Source

pub fn new(data: &'a [u8]) -> Self

A reader at the start of data.

Source

pub fn set_reference_ids(&mut self, ids: Arc<BTreeMap<u32, String>>)

Read external pointers as reference ids (ExternalFactory reference mode, used by saves).

Source

pub fn pos(&self) -> usize

The current position, in bytes.

Source

pub fn remaining(&self) -> usize

The number of bytes left before the end of the readable range.

Source

pub fn slice(&self, start: usize, end: usize) -> Result<&'a [u8]>

Bytes already read or ahead, by absolute position.

Source

pub fn bytes(&mut self, n: usize) -> Result<&'a [u8]>

The next n bytes.

Source

pub fn u8(&mut self) -> Result<u8>

Read a u8.

Source

pub fn bool(&mut self) -> Result<bool>

Read a bool (one byte, not zero is true).

Source

pub fn u32(&mut self) -> Result<u32>

Read a u32.

Source

pub fn i32(&mut self) -> Result<i32>

Read an i32.

Source

pub fn u64(&mut self) -> Result<u64>

Read a u64.

Source

pub fn i64(&mut self) -> Result<i64>

Read an i64.

Source

pub fn i16(&mut self) -> Result<i16>

Read an i16.

Source

pub fn u16(&mut self) -> Result<u16>

Read a u16.

Source

pub fn limit(&mut self, end: usize) -> Result<usize>

Narrow the readable range to end at end (inside the current one); returns the old end for Reader::unlimit.

Source

pub fn unlimit(&mut self, end: usize)

Restore the readable range that limit returned.

Source

pub fn set_pos(&mut self, pos: usize)

Move to a position.

Source

pub fn u32_at(&self, at: usize) -> Option<u32>

The u32 at an absolute offset.

Source

pub fn peek_u32(&self) -> Option<u32>

The next u32 without consuming it (None at the end).

Source

pub fn wstring(&mut self) -> Result<String>

A u32 count of UTF-16 units, the terminating NUL included (0 for an empty string), then the units.

Original: System::String::Serialize, Runtime 0x1800cc1a0.

Source

pub fn f32(&mut self) -> Result<f32>

Read an f32.

Source

pub fn f32s<const N: usize>(&mut self) -> Result<[f32; N]>

Read N f32 values.

Source

pub fn count(&mut self) -> Result<usize>

Element count; rejects negative values.

Source

pub fn string(&mut self) -> Result<String>

Read a string: a length with bit 31 set for 8-bit text (else UTF-16), then the characters with the terminating zero.

Source

pub fn external_ref(&mut self) -> Result<Option<String>>

ExternalPtr: bool present, then a Path\File.rsc:object reference.

Source

pub fn block<T>( &mut self, f: impl FnOnce(&mut Self, u32) -> Result<T>, ) -> Result<T>

Read one block, running f over its payload. Fails unless f consumes it exactly.

Source

pub fn skip_rest(&mut self)

Skip the rest of the current block (for partially decoded types).

Source

pub fn skip_block(&mut self) -> Result<()>

Skip a block without interpreting it.

Auto Trait Implementations§

§

impl<'a> Freeze for Reader<'a>

§

impl<'a> RefUnwindSafe for Reader<'a>

§

impl<'a> Send for Reader<'a>

§

impl<'a> Sync for Reader<'a>

§

impl<'a> Unpin for Reader<'a>

§

impl<'a> UnsafeUnpin for Reader<'a>

§

impl<'a> UnwindSafe for Reader<'a>

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.