pub unsafe trait BufferMut<S: ?Sized>: Buffer<S> {
// Required methods
fn as_mut_slice(&mut self) -> &mut S;
fn capacity(&self) -> usize;
unsafe fn set_len(&mut self, len: usize) -> bool;
fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError>;
}
Expand description
A buffer that contains a mutable slice.
The buffer may be resizable, and the whole slice may have an uninitialized section.
§Safety
as_mut_slice
must return the same slice asBuffer::as_slice
- The full buffer slice must have at least
capacity
maybe uninitialized items;as_mut_slice
returns in fact the beginning of the full slice. - Accessing
capacity
must not invalidate the buffer slice. - If
set_len
returnstrue
, then the length ofas_mut_slice
must have been updated accordingly. - If
try_reserve
returns successfully, thencapacity
must have been increased by at leastadditional
items. - If the buffer implements
BorrowMetadata
, thenborrow_metadata
must not invalidate the buffer slice.
Required Methods§
Sourcefn as_mut_slice(&mut self) -> &mut S
fn as_mut_slice(&mut self) -> &mut S
Returns the mutable buffer slice.
Sourceunsafe fn set_len(&mut self, len: usize) -> bool
unsafe fn set_len(&mut self, len: usize) -> bool
Set the length of the buffer slice.
Returns false
if this operation is not supported, for example for fixed size buffers
like AsMutBuffer
.
§Safety
First len
items of buffer slice must be initialized.
Sourcefn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError>
fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError>
Tries reserving capacity for at least additional
items.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.