pub struct MutableBuffer { /* fields omitted */ }
Similar to Buffer
, but is growable and can be mutated. A mutable buffer can be
converted into a immutable buffer via the freeze
method.
Allocate a new mutable buffer with initial capacity to be capacity
.
Set the bits in the range of [0, end)
to 0 (if val
is false), or 1 (if val
is true). Also extend the length of this buffer to be end
.
This is useful when one wants to clear (or set) the bits and then manipulate
the buffer directly (e.g., modifying the buffer by holding a mutable reference
from data_mut()
).
Ensure that count
bytes from start
contain zero bits
This is used to initialize the bits in a buffer, however, it has no impact on the len
of the buffer and so can be used to initialize the memory region from len
to capacity
.
Ensures that this buffer has at least capacity
slots in this buffer. This will
also ensure the new capacity will be a multiple of 64 bytes.
Returns the new capacity for this buffer.
Resizes the buffer so that the len
will equal to the new_len
.
If new_len
is greater than len
, the buffer's length is simply adjusted to be
the former, optionally extending the capacity. The data between len
and
new_len
will remain unchanged.
If new_len
is less than len
, the buffer will be truncated.
Returns whether this buffer is empty or not.
Returns the length (the number of bytes written) in this buffer.
Returns the total capacity in this buffer.
Clear all existing data from this buffer.
Returns the data stored in this buffer as a slice.
Returns the data stored in this buffer as a mutable slice.
Returns a raw pointer for this buffer.
Note that this should be used cautiously, and the returned pointer should not be
stored anywhere, to avoid dangling pointers.
Freezes this buffer and return an immutable version of it.
Executes the destructor for this type. Read more
This method tests for self
and other
values to be equal, and is used by ==
. Read more
This method tests for !=
.
Formats the value using the given formatter. Read more
Write a buffer into this object, returning how many bytes were written. Read more
Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
Attempts to write an entire buffer into this write. Read more
Writes a formatted string into this writer, returning any error encountered. Read more
Creates a "by reference" adaptor for this instance of Write
. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Immutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
Mutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)