Struct glib::Bytes [−][src]
pub struct Bytes(_);
Expand description
A shared immutable byte slice (the equivalent of Rc<[u8]>
).
From
implementations that take references (e.g. &[u8]
) copy the
data. The from_static
constructor avoids copying static data.
use glib::Bytes; let v = vec![1, 2, 3]; let b = Bytes::from(&v); assert_eq!(v, b); let s = b"xyz"; let b = Bytes::from_static(s); assert_eq!(&s[..], b);
A simple refcounted data type representing an immutable sequence of zero or more bytes from an unspecified origin.
The purpose of a Bytes
is to keep the memory region that it holds
alive for as long as anyone holds a reference to the bytes. When
the last reference count is dropped, the memory is released. Multiple
unrelated callers can use byte data in the Bytes
without coordinating
their activities, resting assured that the byte data will not change or
move while they hold a reference.
A Bytes
can come from many different origins that may have
different procedures for freeing the memory region. Examples are
memory from g_malloc()
, from memory slices, from a GMappedFile
or
memory from other allocators.
Bytes
work well as keys in GHashTable
. Use g_bytes_equal()
and
g_bytes_hash()
as parameters to g_hash_table_new()
or g_hash_table_new_full()
.
Bytes
can also be used as keys in a GTree
by passing the g_bytes_compare()
function to g_tree_new()
.
The data pointed to by this bytes must not be modified. For a mutable
array of bytes see ByteArray
. Use [unref_to_array()
][Self::unref_to_array()] to create a
mutable array for a Bytes
sequence. To create an immutable Bytes
from
a mutable ByteArray
, use the [ByteArray::free_to_bytes()
][crate::ByteArray::free_to_bytes()] function.
Implementations
Creates a view into static data
without copying.
Trait Implementations
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
Returns the type identifier of Self
.
Auto Trait Implementations
Blanket Implementations
Mutably borrows from an owned value. Read more
Returns a SendValue
clone of self
.
impl<'a, T, C> FromValueOptional<'a> for T where
C: ValueTypeChecker<Error = ValueTypeMismatchOrNoneError>,
T: FromValue<'a, Checker = C>,