pub struct QByteArray { /* private fields */ }Expand description
The QByteArray class provides an array of bytes.
Qt Documentation: QByteArray
Implementations§
Source§impl QByteArray
impl QByteArray
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if the byte array has size 0; otherwise returns false.
Sourcepub fn is_lower(&self) -> bool
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.
Sourcepub fn is_null(&self) -> bool
pub fn is_null(&self) -> bool
Returns true if this byte array is null; otherwise returns false.
Sourcepub fn is_upper(&self) -> bool
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.
Sourcepub fn to_base64(&self, options: QByteArrayBase64Options) -> QByteArray
pub fn to_base64(&self, options: QByteArrayBase64Options) -> QByteArray
Returns a copy of the byte array, encoded using the options options.
Source§impl QByteArray
impl QByteArray
Sourcepub fn as_mut_slice(&mut self) -> &mut [u8] ⓘ
pub fn as_mut_slice(&mut self) -> &mut [u8] ⓘ
Extracts a mutable slice of the entire vector.
Sourcepub fn fill(&mut self, ch: u8, size: isize)
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.
Sourcepub fn from_base64_encoding(
base64: &Self,
options: QByteArrayBase64Options,
) -> Result<Self, QByteArrayFromBase64Error>
pub fn from_base64_encoding( base64: &Self, options: QByteArrayBase64Options, ) -> Result<Self, QByteArrayFromBase64Error>
Decodes the Base64 array base64, using the options defined by options.
Sourcepub unsafe fn from_raw_bytes(bytes: &Bytes) -> Self
Available on crate feature bytes only.
pub unsafe fn from_raw_bytes(bytes: &Bytes) -> Self
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
Sourcepub unsafe fn from_raw_data(bytes: &[u8]) -> Self
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
Sourcepub fn insert(&mut self, pos: isize, ch: u8)
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.
Sourcepub fn remove(&mut self, pos: isize, len: isize)
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.
Sourcepub fn reserve(&mut self, size: isize)
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.
Sourcepub fn resize(&mut self, size: isize)
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.
Sourcepub fn simplified(&self) -> Self
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 ' '.
Sourcepub fn to_lower(&self) -> Self
pub fn to_lower(&self) -> Self
Returns a copy of the byte array in which each ASCII uppercase letter converted to lowercase.
Sourcepub fn to_upper(&self) -> Self
pub fn to_upper(&self) -> Self
Returns a copy of the byte array in which each ASCII lowercase letter converted to uppercase.
Sourcepub fn trimmed(&self) -> Self
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
impl AsRef<[u8]> for QByteArray
Source§impl Clone for QByteArray
impl Clone for QByteArray
Source§fn clone(&self) -> Self
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)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for QByteArray
impl Debug for QByteArray
Source§impl<'de> Deserialize<'de> for QByteArray
Available on crate feature serde only.
impl<'de> Deserialize<'de> for QByteArray
serde only.Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Source§impl Display for QByteArray
impl Display for QByteArray
Source§impl Drop for QByteArray
impl Drop for QByteArray
impl Eq for QByteArray
Source§impl ExternType for QByteArray
impl ExternType for QByteArray
Source§impl<'a> From<&'a QByteArray> for QAnyStringView<'a>
Available on cxxqt_qt_version_major=6 only.
impl<'a> From<&'a QByteArray> for QAnyStringView<'a>
cxxqt_qt_version_major=6 only.Source§fn from(bytes: &'a QByteArray) -> Self
fn from(bytes: &'a QByteArray) -> Self
Constructs a QAnyStringView from a QByteArray.
Source§impl From<&Bytes> for QByteArray
Available on crate feature bytes only.
impl From<&Bytes> for QByteArray
bytes only.Source§impl From<&QByteArray> for Vec<u8>
impl From<&QByteArray> for Vec<u8>
Source§fn from(bytearray: &QByteArray) -> Self
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.
impl From<&QByteArray> for Bytes
bytes only.Source§fn from(value: &QByteArray) -> Self
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
impl From<&QByteArray> for QUuid
Source§fn from(value: &QByteArray) -> Self
fn from(value: &QByteArray) -> Self
See QUuid::from_rfc_4122.
Source§impl From<&String> for QByteArray
impl From<&String> for QByteArray
Source§impl From<&[u8]> for QByteArray
impl From<&[u8]> for QByteArray
Source§impl From<&str> for QByteArray
impl From<&str> for QByteArray
Source§impl From<QUuid> for QByteArray
impl From<QUuid> for QByteArray
Source§fn from(value: QUuid) -> Self
fn from(value: QUuid) -> Self
See QUuid::to_rfc_4122.