Skip to main content

QDataStream

Struct QDataStream 

Source
pub struct QDataStream<'a> { /* private fields */ }
Expand description

QDataStream reader for parsing Qt binary serialization format

Implementations§

Source§

impl<'a> QDataStream<'a>

Source

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

Create a new QDataStream reader with Qt 5.1 version

Source

pub const fn with_version(data: &'a [u8], version: u32) -> Self

Create a new QDataStream reader with specified version

Source

pub const fn version(&self) -> u32

Get the Qt version

Source

pub const fn position(&self) -> u64

Get current position in the stream

Source

pub const fn at_end(&self) -> bool

Check if we’ve reached the end of the stream

Source

pub const fn remaining(&self) -> usize

Get remaining bytes count

Source

pub fn skip(&mut self, n: usize) -> Result<()>

Skip n bytes

Source

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

Read a single byte (quint8)

Source

pub fn read_i8(&mut self) -> Result<i8>

Read a signed 8-bit integer (qint8)

Source

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

Read an unsigned 16-bit integer (quint16) - Big Endian

Source

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

Read a signed 16-bit integer (qint16) - Big Endian

Source

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

Read an unsigned 32-bit integer (quint32) - Big Endian

Source

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

Read a signed 32-bit integer (qint32) - Big Endian

Source

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

Read an unsigned 64-bit integer (quint64) - Big Endian

Source

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

Read a signed 64-bit integer (qint64) - Big Endian

Source

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

Read a boolean value

Source

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

Read a 32-bit float - Big Endian

Source

pub fn read_f64(&mut self) -> Result<f64>

Read a 64-bit double - Big Endian

Source

pub fn read_raw(&mut self, len: usize) -> Result<Vec<u8>>

Read raw bytes of specified length

Source

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

Read a QByteArray

Wire format:

  • 4 bytes: length (quint32 BE)
    • 0xFFFFFFFF = null QByteArray (returns empty vec)
    • 0xFFFFFFFE = extended 64-bit length (followed by quint64)
  • N bytes: raw data
Source

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

Read a QString

Wire format:

  • 4 bytes: length in BYTES (not chars!) of UTF-16 data
    • 0xFFFFFFFF = null QString (returns empty string)
  • N bytes: UTF-16 Big Endian encoded characters
Source

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

Read a length-prefixed C string (writeBytes format)

Wire format:

  • 4 bytes: length including null terminator
  • N bytes: string data including null terminator

Trait Implementations§

Source§

impl Debug for QDataStream<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for QDataStream<'a>

§

impl<'a> RefUnwindSafe for QDataStream<'a>

§

impl<'a> Send for QDataStream<'a>

§

impl<'a> Sync for QDataStream<'a>

§

impl<'a> Unpin for QDataStream<'a>

§

impl<'a> UnsafeUnpin for QDataStream<'a>

§

impl<'a> UnwindSafe for QDataStream<'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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more