Skip to main content

QByteArray

Struct QByteArray 

Source
pub struct QByteArray { /* private fields */ }
Expand description

The QByteArray class provides an array of bytes.

Qt Documentation: QByteArray

Implementations§

Source§

impl QByteArray

Source

pub fn clear(&mut self)

Clears the contents of the byte array and makes it null.

Source

pub fn is_empty(&self) -> bool

Returns true if the byte array has size 0; otherwise returns false.

Source

pub fn is_lower(&self) -> bool

Returns true if this byte array is lowercase, that is, if it’s identical to its to_lower folding.

Source

pub fn is_null(&self) -> bool

Returns true if this byte array is null; otherwise returns false.

Source

pub fn is_upper(&self) -> bool

Returns true if this byte array is uppercase, that is, if it’s identical to its to_upper folding.

Source

pub fn squeeze(&mut self)

Releases any memory not required to store the array’s data.

Source

pub fn to_base64(&self, options: QByteArrayBase64Options) -> QByteArray

Returns a copy of the byte array, encoded using the options options.

Source§

impl QByteArray

Source

pub fn append(&mut self, ch: u8)

Inserts value at the end of the list.

Source

pub fn as_mut_slice(&mut self) -> &mut [u8]

Extracts a mutable slice of the entire vector.

Source

pub fn as_slice(&self) -> &[u8]

Extracts a slice containing the entire byte array.

Source

pub fn fill(&mut self, ch: u8, size: isize)

Sets every byte in the byte array to ch. If size is different from -1, the byte array is resized to size size beforehand.

Source

pub fn from_base64_encoding( base64: &Self, options: QByteArrayBase64Options, ) -> Result<Self, QByteArrayFromBase64Error>

Decodes the Base64 array base64, using the options defined by options.

Source

pub unsafe fn from_raw_bytes(bytes: &Bytes) -> Self

Available on crate feature bytes only.

Construct a QByteArray from a bytes::Bytes without a deep copy

§Safety

The caller must ensure that the original bytes::Bytes outlives the QByteArray and that the QByteArray is not modified

Source

pub unsafe fn from_raw_data(bytes: &[u8]) -> Self

Construct a QByteArray from a &[u8] without a deep copy

§Safety

The caller must ensure that the original slice outlives the QByteArray and that the QByteArray is not modified

Source

pub fn insert(&mut self, pos: isize, ch: u8)

Inserts byte ch at index position pos in the byte array.

This array grows to accommodate the insertion. If pos is beyond the end of the array, the array is first extended with space characters to reach this pos.

Source

pub fn len(&self) -> isize

Returns the number of bytes in this byte array.

Source

pub fn prepend(&mut self, ch: u8)

Prepends the byte ch to this byte array.

Source

pub fn remove(&mut self, pos: isize, len: isize)

Removes len bytes from the array, starting at index position pos.

If pos is out of range, nothing happens. If pos is valid, but pos + len is larger than the size of the array, the array is truncated at position pos.

Source

pub fn reserve(&mut self, size: isize)

Attempts to allocate memory for at least size bytes.

If you know in advance how large the byte array will be, you can call this function, and if you call resize often you are likely to get better performance.

If in doubt about how much space shall be needed, it is usually better to use an upper bound as size, or a high estimate of the most likely size, if a strict upper bound would be much bigger than this. If size is an underestimate, the array will grow as needed once the reserved size is exceeded, which may lead to a larger allocation than your best overestimate would have and will slow the operation that triggers it.

The sole purpose of this function is to provide a means of fine tuning QByteArray’s memory usage. In general, you will rarely ever need to call this function.

Source

pub fn resize(&mut self, size: isize)

Sets the size of the byte array to size bytes.

If size is greater than the current size, the byte array is extended to make it size bytes with the extra bytes added to the end. The new bytes are uninitialized.

If size is less than the current size, bytes beyond position size are excluded from the byte array.

Note: While resize will grow the capacity if needed, it never shrinks capacity.

Source

pub fn simplified(&self) -> Self

Returns a copy of this byte array that has spacing characters removed from the start and end, and in which each sequence of internal spacing characters is replaced with a single space.

The spacing characters are the ASCII characters tabulation '\t', line feed '\n', carriage return '\r', vertical tabulation '\x08' ('\v' in C), form feed '\x0C' ('\f' in C), and space ' '.

Source

pub fn to_lower(&self) -> Self

Returns a copy of the byte array in which each ASCII uppercase letter converted to lowercase.

Source

pub fn to_upper(&self) -> Self

Returns a copy of the byte array in which each ASCII lowercase letter converted to uppercase.

Source

pub fn trimmed(&self) -> Self

Returns a copy of this byte array with spacing characters removed from the start and end.

The spacing characters are the ASCII characters tabulation '\t', line feed '\n', carriage return '\r', vertical tabulation '\x08' ('\v' in C), form feed '\x0C' ('\f' in C), and space ' '.

Trait Implementations§

Source§

impl AsRef<[u8]> for QByteArray

Source§

fn as_ref(&self) -> &[u8]

Construct a slice of u8 from a QByteArray.

Source§

impl Clone for QByteArray

Source§

fn clone(&self) -> Self

Constructs a copy of self.

This operation takes constant time, because QByteArray is implicitly shared similar to a Cow. This makes returning a QByteArray from a function very fast. If a shared instance is modified, it will be copied (copy-on-write), and that takes linear time.

1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for QByteArray

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for QByteArray

Source§

fn default() -> Self

Constructs an empty byte array.

Source§

impl<'de> Deserialize<'de> for QByteArray

Available on crate feature serde only.
Source§

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for QByteArray

Source§

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

Convert the QByteArray to a Rust string.

Source§

impl Drop for QByteArray

Source§

fn drop(&mut self)

Destroys the byte array.

Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl Eq for QByteArray

Source§

impl ExternType for QByteArray

Source§

type Id = (Q, B, y, t, e, A, r, r, a, y)

A type-level representation of the type’s C++ namespace and type name. Read more
Source§

type Kind = Trivial

Source§

impl<'a> From<&'a QByteArray> for QAnyStringView<'a>

Available on cxxqt_qt_version_major=6 only.
Source§

fn from(bytes: &'a QByteArray) -> Self

Constructs a QAnyStringView from a QByteArray.

Source§

impl From<&Bytes> for QByteArray

Available on crate feature bytes only.
Source§

fn from(value: &Bytes) -> Self

Convert bytes::Bytes to a QByteArray. This makes a deep copy of the data.

Source§

impl From<&QByteArray> for Vec<u8>

Source§

fn from(bytearray: &QByteArray) -> Self

Convert the QByteArray to a Vec<u8>. This makes a deep copy of the data.

Source§

impl From<&QByteArray> for Bytes

Available on crate feature bytes only.
Source§

fn from(value: &QByteArray) -> Self

Convert QByteArray to a bytes::Bytes. This makes a deep copy of the data.

Source§

impl From<&QByteArray> for QUuid

Source§

impl From<&String> for QByteArray

Source§

fn from(str: &String) -> Self

Constructs a QByteArray from a Rust string. This makes a deep copy of the data.

Source§

impl<const N: usize> From<&[u8; N]> for QByteArray

Source§

fn from(bytes: &[u8; N]) -> Self

Converts to this type from the input type.
Source§

impl From<&[u8]> for QByteArray

Source§

fn from(bytes: &[u8]) -> Self

Constructs a QByteArray from a &[u8]. This makes a deep copy of the data.

Source§

impl From<&str> for QByteArray

Source§

fn from(str: &str) -> Self

Constructs a QByteArray from a Rust string slice. This makes a deep copy of the data.

Source§

impl From<QUuid> for QByteArray

Source§

fn from(value: QUuid) -> Self

Source§

impl PartialEq for QByteArray

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl QListElement for QByteArray

Source§

type TypeId = (Q, L, i, s, t, __, Q, B, y, t, e, A, r, r, a, y)

Source§

fn append(list: &mut QList<Self>, value: Self)

Source§

fn append_clone(list: &mut QList<Self>, value: &Self)

Source§

fn clear(list: &mut QList<Self>)

Source§

fn clone(list: &QList<Self>) -> QList<Self>

Source§

fn contains(list: &QList<Self>, value: &Self) -> bool

Source§

fn default() -> QList<Self>

Source§

fn drop(list: &mut QList<Self>)

Source§

unsafe fn get_unchecked(list: &QList<Self>, pos: isize) -> &Self

Safety Read more
Source§

fn index_of(list: &QList<Self>, value: &Self) -> isize

Source§

fn insert(list: &mut QList<Self>, pos: isize, value: Self)

Source§

fn insert_clone(list: &mut QList<Self>, pos: isize, value: &Self)

Source§

fn len(list: &QList<Self>) -> isize

Source§

fn remove(list: &mut QList<Self>, pos: isize)

Source§

fn reserve(list: &mut QList<Self>, size: isize)

Source§

impl QSetElement for QByteArray

Source§

type TypeId = (Q, S, e, t, __, Q, B, y, t, e, A, r, r, a, y)

Source§

fn clear(set: &mut QSet<Self>)

Source§

fn clone(set: &QSet<Self>) -> QSet<Self>

Source§

fn contains(set: &QSet<Self>, value: &Self) -> bool

Source§

fn default() -> QSet<Self>

Source§

fn drop(set: &mut QSet<Self>)

Source§

unsafe fn get_unchecked(set: &QSet<Self>, pos: isize) -> &Self

Safety Read more
Source§

fn insert(set: &mut QSet<Self>, value: Self)

Source§

fn insert_clone(set: &mut QSet<Self>, value: &Self)

Source§

fn len(set: &QSet<Self>) -> isize

Source§

fn remove(set: &mut QSet<Self>, value: &Self) -> bool

Source§

fn reserve(set: &mut QSet<Self>, size: isize)

Source§

impl QVariantValue for QByteArray

Source§

fn can_convert(variant: &QVariant) -> bool

Source§

fn construct(value: &Self) -> QVariant

Source§

fn value_or_default(variant: &QVariant) -> Self

Source§

impl QVectorElement for QByteArray

Source§

type TypeId = (Q, V, e, c, t, o, r, __, Q, B, y, t, e, A, r, r, a, y)

Source§

fn append(vector: &mut QVector<Self>, value: Self)

Source§

fn append_clone(vector: &mut QVector<Self>, value: &Self)

Source§

fn clear(vector: &mut QVector<Self>)

Source§

fn clone(vector: &QVector<Self>) -> QVector<Self>

Source§

fn contains(vector: &QVector<Self>, value: &Self) -> bool

Source§

fn default() -> QVector<Self>

Source§

fn drop(vector: &mut QVector<Self>)

Source§

unsafe fn get_unchecked(vector: &QVector<Self>, pos: isize) -> &Self

Safety Read more
Source§

fn index_of(vector: &QVector<Self>, value: &Self) -> isize

Source§

fn insert(vector: &mut QVector<Self>, pos: isize, value: Self)

Source§

fn insert_clone(vector: &mut QVector<Self>, pos: isize, value: &Self)

Source§

fn len(vector: &QVector<Self>) -> isize

Source§

fn remove(vector: &mut QVector<Self>, pos: isize)

Source§

fn reserve(vector: &mut QVector<Self>, size: isize)

Source§

impl Serialize for QByteArray

Available on crate feature serde only.
Source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.