pub struct ArcSliceMut<S: Slice + ?Sized, L: LayoutMut = DefaultLayoutMut, const UNIQUE: bool = true> { /* private fields */ }Expand description
A thread-safe, mutable and growable container.
ArcSliceMut has a smaller choice of layout than ArcSlice, but can also wrap arbitrary
buffers such asVec, memory-mapped files, etc. Arbitrary metadata can also be attached to the
buffer for contextual or domain-specific needs.
With UNIQUE=true, ArcSliceMut is roughly equivalent to a Vec. Additional capacity
can be reserved and the slice can be extended. With UNIQUE=false, the slice may be shared,
meaning that multiple ArcSliceMut may reference non-intersecting portions of the underlying
buffer. In that case, capacity reservation might fail, but the slice will never be implicitly
reallocated and copied. In any case, ArcSliceMut is cheaply convertible to ArcSlice.
It is mainly intended to manipulate [u8]/str byte slices, to facilitate zero-copy
operations in network programming, hence the aliases ArcBytesMut/ArcStrMut. But it can
actually handle any type of slices, from strings with specific invariants to primitive slices
with droppable items.
§Examples
use arc_slice::{ArcSlice, ArcSliceMut};
let mut s = ArcSliceMut::<[u8]>::with_capacity(64);
s.push(b'h');
s.extend_from_slice(b"ello");
assert_eq!(s, b"hello");
let mut s = s.into_shared();
let mut s2 = s.split_off(3);
s.copy_from_slice(b"bye");
s2.copy_from_slice(b"!!");
s.try_unsplit(s2).unwrap();
assert_eq!(s, b"bye!!");
let frozen: ArcSlice<[u8]> = s.freeze();
assert_eq!(frozen, b"bye!!");With shared memory:
use std::{
fs::File,
path::{Path, PathBuf},
};
use arc_slice::{buffer::AsMutBuffer, error::TryReserveError, layout::ArcLayout, ArcSliceMut};
use memmap2::MmapMut;
let path = Path::new("README.md").to_owned();
let file = File::options().read(true).write(true).open(&path)?;
let mmap = unsafe { MmapMut::map_mut(&file)? };
let buffer = unsafe { AsMutBuffer::new(mmap) };
let mut bytes: ArcSliceMut<[u8], ArcLayout<true>> =
ArcSliceMut::from_buffer_with_metadata(buffer, path);
bytes[..11].copy_from_slice(b"# arc-slice");
assert!(bytes.starts_with(b"# arc-slice"));
assert_eq!(bytes.metadata::<PathBuf>().unwrap(), Path::new("README.md"));Implementations§
Source§impl<S: Slice + ?Sized, L: LayoutMut, const UNIQUE: bool> ArcSliceMut<S, L, UNIQUE>
impl<S: Slice + ?Sized, L: LayoutMut, const UNIQUE: bool> ArcSliceMut<S, L, UNIQUE>
Sourcepub const fn len(&self) -> usize
pub const fn len(&self) -> usize
Returns the number of items in the slice.
§Examples
use arc_slice::ArcSliceMut;
let s = ArcSliceMut::<[u8]>::from(&[0, 1, 2]);
assert_eq!(s.len(), 3);Sourcepub const fn is_empty(&self) -> bool
pub const fn is_empty(&self) -> bool
Returns true if the slice contains no items.
§Examples
use arc_slice::ArcSliceMut;
let s = ArcSliceMut::<[u8]>::from(&[0, 1, 2]);
assert!(!s.is_empty());
let s = ArcSliceMut::<[u8]>::from(&[]);
assert!(s.is_empty());Sourcepub const fn as_ptr(&self) -> *const S::Item
pub const fn as_ptr(&self) -> *const S::Item
Returns a raw pointer to the slice’s first item.
See slice::as_ptr.
Sourcepub fn as_mut_ptr(&mut self) -> *mut S::Item
pub fn as_mut_ptr(&mut self) -> *mut S::Item
Returns a mutable raw pointer to the slice’s first item.
See slice::as_mut_ptr.
Sourcepub fn as_slice(&self) -> &S
pub fn as_slice(&self) -> &S
Returns a reference to the underlying slice.
Equivalent to &self[..].
§Examples
use arc_slice::ArcSliceMut;
let s = ArcSliceMut::<[u8]>::from(b"hello world");
assert_eq!(s.as_slice(), b"hello world");Sourcepub fn as_mut_slice(&mut self) -> &mut S
pub fn as_mut_slice(&mut self) -> &mut S
Returns a mutable reference to the underlying slice.
Equivalent to &mut self[..].
§Examples
use arc_slice::ArcSliceMut;
let mut s = ArcSliceMut::<[u8]>::from(b"hello world");
assert_eq!(s.as_mut_slice(), b"hello world");Sourcepub const fn capacity(&self) -> usize
pub const fn capacity(&self) -> usize
Returns the total number of items the slice can hold without reallocating.
use arc_slice::ArcSliceMut;
let mut s = ArcSliceMut::<[u8]>::with_capacity(64);
s.push(0);
assert_eq!(s.capacity(), 64);Sourcepub unsafe fn spare_capacity_mut(&mut self) -> &mut [MaybeUninit<S::Item>]where
S: Extendable,
pub unsafe fn spare_capacity_mut(&mut self) -> &mut [MaybeUninit<S::Item>]where
S: Extendable,
Returns the remaining spare capacity of the slice.
The returned slice can be used to fill the slice with items before marking the data as
initialized using the set_len method.
§Safety
Writing uninitialized memory may be unsound if the underlying buffer doesn’t support it.
§Examples
use arc_slice::ArcSliceMut;
let mut s = ArcSliceMut::<[u8]>::with_capacity(10);
// SAFETY: no uninit bytes are written
let uninit = unsafe { s.spare_capacity_mut() };
uninit[0].write(0);
uninit[1].write(1);
uninit[2].write(2);
// SAFETY: the first 3 bytes are initialized
unsafe { s.set_len(3) }
assert_eq!(s, [0, 1, 2]);Sourcepub unsafe fn set_len(&mut self, new_len: usize)where
S: Extendable,
pub unsafe fn set_len(&mut self, new_len: usize)where
S: Extendable,
Forces the length of the slice to new_len.
§Safety
First len items of the slice must be initialized.
§Examples
use arc_slice::ArcSliceMut;
let mut s = ArcSliceMut::<[u8]>::with_capacity(10);
// SAFETY: `s.capacity()` >= 3
unsafe { std::ptr::copy_nonoverlapping([0, 1, 2].as_ptr(), s.as_mut_ptr(), 3) };
// SAFETY: the first 3 bytes are initialized
unsafe { s.set_len(3) }
assert_eq!(s, [0, 1, 2]);Sourcepub fn try_push(&mut self, item: S::Item) -> Result<(), TryReserveError>where
S: Extendable,
pub fn try_push(&mut self, item: S::Item) -> Result<(), TryReserveError>where
S: Extendable,
Tries appending an element to the end of the slice, returning an error if the capacity reservation fails.
The buffer might have to reserve additional capacity to do the appending.
The default arc-slice buffer supports amortized reservation, doubling the capacity each time.
§Examples
use arc_slice::ArcSliceMut;
let mut s = ArcSliceMut::<[u8]>::new();
s.try_push(42)?;
assert_eq!(s, [42]);Sourcepub fn try_reclaim(&mut self, additional: usize) -> bool
pub fn try_reclaim(&mut self, additional: usize) -> bool
Tries reclaiming additional capacity for at least additional more items without
reallocating the buffer, returning true if it succeeds.
Does nothing if the spare capacity is greater than the requested one.
Reclaiming means shifting the current slice to the front of the buffer. It is only possible
when the ArcSliceMut is unique, and when the slice doesn’t overlap with the spare
capacity at the buffer front.
The reclaimed capacity might be greater than the requested one.
§Examples
use arc_slice::ArcSliceMut;
let mut s = ArcSliceMut::<[u8]>::from_iter(0..64);
let ptr = s.as_ptr();
s.advance(60);
assert_eq!(s.capacity(), 4);
assert_eq!(s, [60, 61, 62, 63]);
// Reclamation of less than 60 bytes succeeds, bringing back the full capacity.
assert!(s.try_reclaim(16));
assert_eq!(s.capacity(), 64);
assert_eq!(s, [60, 61, 62, 63]);
assert_eq!(s.as_ptr(), ptr);
// Trying reclaiming more capacity fails.
assert!(!s.try_reclaim(100));Sourcepub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError>
pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError>
Tries reserving capacity for at least additional more items, returning an error if the
operation fails.
Does nothing if the spare capacity is greater than the requested one.
Reserving is only possible when the ArcSliceMut is unique, and when it is supported by
the underlying buffer. It always attempts to reclaim first, and
reallocates the buffer if that fails.
The default arc-slice buffer supports amortized reservation, doubling the capacity each time. The reserved capacity might be greater than the requested one.
§Examples
use arc_slice::ArcSliceMut;
let mut s = ArcSliceMut::<[u8]>::new();
s.try_reserve(3)?;
assert!(s.capacity() >= 3);
s.extend_from_slice(&[0, 1, 2]);
assert_eq!(s, [0, 1, 2]);Sourcepub fn try_extend_from_slice(
&mut self,
slice: &S,
) -> Result<(), TryReserveError>
pub fn try_extend_from_slice( &mut self, slice: &S, ) -> Result<(), TryReserveError>
Tries appending a slice to the end of slice, returning an error if the capacity reservation fails.
The buffer might have to reserve additional capacity to do the appending.
The default arc-slice buffer supports amortized reservation, doubling the capacity each time.
use arc_slice::ArcSliceMut;
let mut s = ArcSliceMut::<[u8]>::new();
s.try_extend_from_slice(b"hello world")?;
assert_eq!(s, b"hello world");Sourcepub fn truncate(&mut self, len: usize)
pub fn truncate(&mut self, len: usize)
Truncate the slice to the first len items.
If len is greater than the slice length, this has no effect.
use arc_slice::ArcSliceMut;
let mut s = ArcSliceMut::<[u8]>::from(b"hello world");
s.truncate(5);
assert_eq!(s, b"hello");Sourcepub fn metadata<M: Any>(&self) -> Option<&M>
pub fn metadata<M: Any>(&self) -> Option<&M>
Accesses the metadata of the underlying buffer if it can be successfully downcast.
§Examples
use arc_slice::{layout::ArcLayout, ArcSliceMut};
let metadata = "metadata".to_string();
let s =
ArcSliceMut::<[u8], ArcLayout<true>>::from_buffer_with_metadata(vec![0, 1, 2], metadata);
assert_eq!(s.metadata::<String>().unwrap(), "metadata");Sourcepub fn try_into_buffer<B: BufferMut<S>>(self) -> Result<B, Self>
pub fn try_into_buffer<B: BufferMut<S>>(self) -> Result<B, Self>
Tries downcasting the ArcSliceMut to its underlying buffer.
§Examples
use arc_slice::{layout::ArcLayout, ArcSliceMut};
let s = ArcSliceMut::<[u8], ArcLayout<true>>::from(vec![0, 1, 2]);
assert_eq!(s.try_into_buffer::<Vec<u8>>().unwrap(), [0, 1, 2]);Sourcepub fn try_into_unique(self) -> Result<ArcSliceMut<S, L, true>, Self>
pub fn try_into_unique(self) -> Result<ArcSliceMut<S, L, true>, Self>
Tries turning the shared ArcSliceMut into a unique one.
§Examples
use arc_slice::ArcSliceMut;
let mut a = ArcSliceMut::<[u8]>::from(b"hello world").into_shared();
let b = a.split_to(5);
assert!(a.try_into_unique().is_err());
// a has been dropped
assert!(b.try_into_unique().is_ok());Turns the unique ArcSliceMut into a shared one.
Shared ArcSliceMut can be split.
§Examples
use arc_slice::ArcSliceMut;
let mut a = ArcSliceMut::<[u8]>::from(b"hello world").into_shared();
let b = a.split_to(5);Sourcepub fn try_freeze<L2: Layout>(self) -> Result<ArcSlice<S, L2>, Self>
pub fn try_freeze<L2: Layout>(self) -> Result<ArcSlice<S, L2>, Self>
Tries freezing the slice, returning an immutable ArcSlice.
If the mutable slice was split into several parts, only the current one is frozen.
The conversion may allocate depending on the given layouts, but allocation errors are caught and the original slice is returned in this case.
§Examples
use arc_slice::{layout::DefaultLayoutMut, ArcSlice, ArcSliceMut};
let mut s = ArcSliceMut::<[u8]>::with_capacity(16);
s.extend_from_slice(b"hello world");
let frozen: ArcSlice<[u8]> = s.try_freeze().unwrap();Sourcepub fn try_with_layout<L2: LayoutMut>(
self,
) -> Result<ArcSliceMut<S, L2, UNIQUE>, Self>
pub fn try_with_layout<L2: LayoutMut>( self, ) -> Result<ArcSliceMut<S, L2, UNIQUE>, Self>
Tries to replace the layout of the ArcSliceMut, returning the original slice if it fails.
The layouts must be compatible for the conversion to succeed, see
FromLayout.
The conversion may allocate depending on the given layouts, but allocation errors are caught and the original slice is also returned in this case.
§Examples
use arc_slice::{
layout::{ArcLayout, BoxedSliceLayout, VecLayout},
ArcSliceMut,
};
let a = ArcSliceMut::<[u8], VecLayout>::from(vec![0, 1, 2]);
let b = a.try_with_layout::<ArcLayout<true>>().unwrap();
assert!(b.try_with_layout::<ArcLayout<false>>().is_err());Sourcepub fn into_arc_slice_mut(self) -> ArcSliceMut<[S::Item], L, UNIQUE>
pub fn into_arc_slice_mut(self) -> ArcSliceMut<[S::Item], L, UNIQUE>
Converts an ArcSliceMut into a primitive ArcSliceMut.
§Examples
use arc_slice::ArcSliceMut;
let s = ArcSliceMut::<str>::from("hello world");
let bytes: ArcSliceMut<[u8]> = s.into_arc_slice_mut();
assert_eq!(bytes, b"hello world");Sourcepub fn try_from_arc_slice_mut(
slice: ArcSliceMut<[S::Item], L, UNIQUE>,
) -> Result<Self, (S::TryFromSliceError, ArcSliceMut<[S::Item], L, UNIQUE>)>
pub fn try_from_arc_slice_mut( slice: ArcSliceMut<[S::Item], L, UNIQUE>, ) -> Result<Self, (S::TryFromSliceError, ArcSliceMut<[S::Item], L, UNIQUE>)>
Tries converting an item slice into the given ArcSliceMut.
The conversion uses Slice::try_from_slice_mut.
§Examples
use arc_slice::ArcSliceMut;
let utf8 = ArcSliceMut::<[u8]>::from(b"hello world");
let not_utf8 = ArcSliceMut::<[u8]>::from(b"\x80\x81");
assert!(ArcSliceMut::<str>::try_from_arc_slice_mut(utf8).is_ok());
assert!(ArcSliceMut::<str>::try_from_arc_slice_mut(not_utf8).is_err());Sourcepub unsafe fn from_arc_slice_mut_unchecked(
slice: ArcSliceMut<[S::Item], L, UNIQUE>,
) -> Self
pub unsafe fn from_arc_slice_mut_unchecked( slice: ArcSliceMut<[S::Item], L, UNIQUE>, ) -> Self
Converts an item slice into the given ArcSliceMut, without checking the slice validity.
§Safety
The operation has the same contract as Slice::from_slice_mut_unchecked.
§Examples
use arc_slice::ArcSliceMut;
let utf8 = ArcSliceMut::<[u8]>::from(b"hello world");
// SAFETY: `utf8` is a valid utf8 string
let s = unsafe { ArcSliceMut::<str>::from_arc_slice_mut_unchecked(utf8) };
assert_eq!(s, "hello world");Source§impl<S: Slice + ?Sized, L: LayoutMut, const UNIQUE: bool> ArcSliceMut<S, L, UNIQUE>
impl<S: Slice + ?Sized, L: LayoutMut, const UNIQUE: bool> ArcSliceMut<S, L, UNIQUE>
Sourcepub fn freeze<L2: FromLayout<L>>(self) -> ArcSlice<S, L2>
Available on crate feature oom-handling only.
pub fn freeze<L2: FromLayout<L>>(self) -> ArcSlice<S, L2>
oom-handling only.Freeze the slice, returning an immutable ArcSlice.
If the mutable slice was split into several parts, only the current one is frozen.
§Examples
use arc_slice::{layout::DefaultLayoutMut, ArcSlice, ArcSliceMut};
let mut s = ArcSliceMut::<[u8]>::with_capacity(16);
s.extend_from_slice(b"hello world");
let frozen: ArcSlice<[u8]> = s.freeze();Sourcepub fn with_layout<L2: LayoutMut + FromLayout<L>>(
self,
) -> ArcSliceMut<S, L2, UNIQUE>
Available on crate feature oom-handling only.
pub fn with_layout<L2: LayoutMut + FromLayout<L>>( self, ) -> ArcSliceMut<S, L2, UNIQUE>
oom-handling only.Replace the layout of the ArcSliceMut.
The layouts must be compatible, see FromLayout.
§Examples
use arc_slice::{
layout::{ArcLayout, BoxedSliceLayout, VecLayout},
ArcSliceMut,
};
let a = ArcSliceMut::<[u8]>::from(b"hello world");
let b = a.with_layout::<VecLayout>();Source§impl<S: Slice + ?Sized, L: LayoutMut> ArcSliceMut<S, L>
impl<S: Slice + ?Sized, L: LayoutMut> ArcSliceMut<S, L>
Sourcepub const fn new() -> Selfwhere
S: Emptyable,
pub const fn new() -> Selfwhere
S: Emptyable,
Creates a new empty ArcSliceMut.
This operation doesn’t allocate.
§Examples
use arc_slice::{layout::ArcLayout, ArcSliceMut};
let s = ArcSliceMut::<[u8]>::new();
assert_eq!(s, []);Sourcepub fn from_slice(slice: &S) -> Self
Available on crate feature oom-handling only.
pub fn from_slice(slice: &S) -> Self
oom-handling only.Sourcepub fn try_from_slice(slice: &S) -> Result<Self, AllocError>
pub fn try_from_slice(slice: &S) -> Result<Self, AllocError>
Tries creating a new ArcSliceMut by copying the given slice, returning an error if the
allocation fails.
§Examples
use arc_slice::ArcSliceMut;
let s = ArcSliceMut::<[u8]>::try_from_slice(b"hello world")?;
assert_eq!(s, b"hello world");Sourcepub fn with_capacity(capacity: usize) -> Selfwhere
S: Emptyable,
Available on crate feature oom-handling only.
pub fn with_capacity(capacity: usize) -> Selfwhere
S: Emptyable,
oom-handling only.Creates a new ArcSliceMut with the given capacity.
This operation allocates if capacity > 0.
§Panics
Panics if the new capacity exceeds isize::MAX - size_of::<usize>() bytes.
§Examples
use arc_slice::ArcSliceMut;
let s = ArcSliceMut::<[u8]>::with_capacity(64);
assert_eq!(s, []);
assert_eq!(s.capacity(), 64);Sourcepub fn try_with_capacity(capacity: usize) -> Result<Self, AllocError>where
S: Emptyable,
Available on crate feature oom-handling only.
pub fn try_with_capacity(capacity: usize) -> Result<Self, AllocError>where
S: Emptyable,
oom-handling only.Tries creating a new ArcSliceMut with the given capacity, returning an error if an
allocation fails.
This operation allocates if capacity > 0.
§Panics
Panics if the new capacity exceeds isize::MAX - size_of::<usize>() bytes.
§Examples
use arc_slice::ArcSliceMut;
let s = ArcSliceMut::<[u8]>::try_with_capacity(64)?;
assert_eq!(s, []);
assert_eq!(s.capacity(), 64);Sourcepub fn zeroed(length: usize) -> Selfwhere
S: Zeroable,
Available on crate feature oom-handling only.
pub fn zeroed(length: usize) -> Selfwhere
S: Zeroable,
oom-handling only.Creates a new zeroed ArcSliceMut with the given capacity.
This operation allocates if capacity > 0. All the items are initialized to 0.
§Panics
Panics if the new capacity exceeds isize::MAX - size_of::<usize>() bytes.
§Examples
use arc_slice::ArcSliceMut;
let s = ArcSliceMut::<[u8]>::zeroed(4);
assert_eq!(s, [0, 0, 0, 0]);
assert_eq!(s.capacity(), 4);Sourcepub fn try_zeroed(length: usize) -> Result<Self, AllocError>where
S: Zeroable,
pub fn try_zeroed(length: usize) -> Result<Self, AllocError>where
S: Zeroable,
Tries creating a new zeroed ArcSliceMut with the given capacity.
This operation allocates if capacity > 0. All the items are initialized to 0.
§Panics
Panics if the new capacity exceeds isize::MAX - size_of::<usize>() bytes.
§Examples
use arc_slice::ArcSliceMut;
let s = ArcSliceMut::<[u8]>::zeroed(4);
assert_eq!(s, [0, 0, 0, 0]);
assert_eq!(s.capacity(), 4);Sourcepub fn reserve(&mut self, additional: usize)
Available on crate feature oom-handling only.
pub fn reserve(&mut self, additional: usize)
oom-handling only.Reserve capacity for at least additional more items.
Does nothing if the spare capacity is greater than the requested one.
Reserving always attempts to reclaim first, and reallocates the buffer if that fails.
The default arc-slice buffer supports amortized reservation, doubling the capacity each time. The reserved capacity might be greater than the requested one.
§Panics
Panics if the new capacity exceeds isize::MAX bytes, or if the underlying buffer doesn’t support additional capacity reservation.
§Examples
use arc_slice::ArcSliceMut;
let mut s = ArcSliceMut::<[u8]>::new();
s.reserve(3);
assert!(s.capacity() >= 3);
s.extend_from_slice(&[0, 1, 2]);
assert_eq!(s, [0, 1, 2]);Sourcepub fn push(&mut self, item: S::Item)where
S: Extendable,
Available on crate feature oom-handling only.
pub fn push(&mut self, item: S::Item)where
S: Extendable,
oom-handling only.Appends an element to the end of the slice.
The buffer might have to reserve additional capacity to do the appending.
The default arc-slice buffer supports amortized reservation, doubling the capacity each time.
§Panics
See reserve.
§Examples
use arc_slice::ArcSliceMut;
let mut s = ArcSliceMut::<[u8]>::new();
s.push(42);
assert_eq!(s, [42]);Sourcepub fn extend_from_slice(&mut self, slice: &S)
Available on crate feature oom-handling only.
pub fn extend_from_slice(&mut self, slice: &S)
oom-handling only.Appends a slice to the end of slice.
The buffer might have to reserve additional capacity to do the appending.
The default arc-slice buffer supports amortized reservation, doubling the capacity each time.
§Panics
See reserve.
use arc_slice::ArcSliceMut;
let mut s = ArcSliceMut::<[u8]>::new();
s.extend_from_slice(b"hello world");
assert_eq!(s, b"hello world");Source§impl<T: Send + Sync + 'static, L: LayoutMut> ArcSliceMut<[T], L>
impl<T: Send + Sync + 'static, L: LayoutMut> ArcSliceMut<[T], L>
Sourcepub fn from_array<const N: usize>(array: [T; N]) -> Self
Available on crate feature oom-handling only.
pub fn from_array<const N: usize>(array: [T; N]) -> Self
oom-handling only.Sourcepub fn try_from_array<const N: usize>(array: [T; N]) -> Result<Self, [T; N]>
pub fn try_from_array<const N: usize>(array: [T; N]) -> Result<Self, [T; N]>
Tries creating a new ArcSliceMut by moving the given array,
returning it if an allocation fails.
§Examples
use arc_slice::ArcSliceMut;
let s = ArcSliceMut::<[u8]>::try_from_array([0, 1, 2]).unwrap();
assert_eq!(s, [0, 1, 2]);Source§impl<S: Slice + ?Sized, L: LayoutMut> ArcSliceMut<S, L, false>
impl<S: Slice + ?Sized, L: LayoutMut> ArcSliceMut<S, L, false>
Sourcepub fn try_split_off(&mut self, at: usize) -> Result<Self, AllocError>
pub fn try_split_off(&mut self, at: usize) -> Result<Self, AllocError>
Tries splitting the slice into two at the given index, returning an error if an allocation fails.
Afterwards self contains elements [0, at), and the returned ArcSliceMut
contains elements [at, len). This operation does not touch the underlying buffer.
The operation may allocate. See CloneNoAllocLayout
documentation for cases where it does not.
§Panics
Panics if at > self.len().
§Examples
use arc_slice::ArcSliceMut;
let mut a = ArcSliceMut::<[u8]>::from(b"hello world").into_shared();
let b = a.try_split_off(5)?;
assert_eq!(a, b"hello");
assert_eq!(b, b" world");Sourcepub fn try_split_to(&mut self, at: usize) -> Result<Self, AllocError>
pub fn try_split_to(&mut self, at: usize) -> Result<Self, AllocError>
Tries splitting the slice into two at the given index, returning an error if an allocation fails.
Afterwards self contains elements [at, len), and the returned ArcSliceMut
contains elements [0, at). This operation does not touch the underlying buffer.
The operation may allocate. See CloneNoAllocLayout
documentation for cases where it does not.
§Panics
Panics if at > self.len().
§Examples
use arc_slice::ArcSliceMut;
let mut a = ArcSliceMut::<[u8]>::from(b"hello world").into_shared();
let b = a.try_split_to(5)?;
assert_eq!(a, b" world");
assert_eq!(b, b"hello");Sourcepub fn try_unsplit(
&mut self,
other: ArcSliceMut<S, L, false>,
) -> Result<(), ArcSliceMut<S, L, false>>
pub fn try_unsplit( &mut self, other: ArcSliceMut<S, L, false>, ) -> Result<(), ArcSliceMut<S, L, false>>
Tries unsplitting two parts of a previously split slice.
§Examples
use arc_slice::ArcSliceMut;
let mut a = ArcSliceMut::<[u8]>::from(b"hello world").into_shared();
let b = a.split_off(5);
assert_eq!(a, b"hello");
assert_eq!(b, b" world");
a.try_unsplit(b).unwrap();
assert_eq!(a, b"hello world");
assert!(a
.try_unsplit(ArcSliceMut::from(b"other").into_shared())
.is_err());Source§impl<S: Slice + ?Sized, L: LayoutMut> ArcSliceMut<S, L, false>
impl<S: Slice + ?Sized, L: LayoutMut> ArcSliceMut<S, L, false>
Sourcepub fn split_off(&mut self, at: usize) -> Self
pub fn split_off(&mut self, at: usize) -> Self
Splits the slice into two at the given index.
Afterwards self contains elements [0, at), and the returned ArcSliceMut
contains elements [at, len). This operation does not touch the underlying buffer.
§Panics
Panics if at > self.capacity().
§Examples
use arc_slice::ArcSliceMut;
let mut a = ArcSliceMut::<[u8]>::from(b"hello world").into_shared();
let b = a.split_off(5);
assert_eq!(a, b"hello");
assert_eq!(b, b" world");Sourcepub fn split_to(&mut self, at: usize) -> Self
pub fn split_to(&mut self, at: usize) -> Self
Splits the slice into two at the given index.
Afterwards self contains elements [at, len), and the returned ArcSliceMut
contains elements [0, at). This operation does not touch the underlying buffer.
§Panics
Panics if at > self.len().
§Examples
use arc_slice::ArcSliceMut;
let mut a = ArcSliceMut::<[u8]>::from(b"hello world").into_shared();
let b = a.split_to(5);
assert_eq!(a, b" world");
assert_eq!(b, b"hello");Source§impl<S: Slice + ?Sized, L: AnyBufferLayout + LayoutMut> ArcSliceMut<S, L>
impl<S: Slice + ?Sized, L: AnyBufferLayout + LayoutMut> ArcSliceMut<S, L>
Sourcepub fn from_buffer<B: BufferMut<S>>(buffer: B) -> Self
Available on crate feature oom-handling only.
pub fn from_buffer<B: BufferMut<S>>(buffer: B) -> Self
oom-handling only.Creates a new ArcSliceMut with the given underlying buffer.
The buffer can be extracted back using try_into_buffer.
§Examples
use arc_slice::{layout::ArcLayout, ArcSliceMut};
let s = ArcSliceMut::<[u8], ArcLayout<true>>::from_buffer(vec![0, 1, 2]);
assert_eq!(s, [0, 1, 2]);
assert_eq!(s.try_into_buffer::<Vec<u8>>().unwrap(), vec![0, 1, 2]);Sourcepub fn try_from_buffer<B: BufferMut<S>>(buffer: B) -> Result<Self, B>
pub fn try_from_buffer<B: BufferMut<S>>(buffer: B) -> Result<Self, B>
Tries creating a new ArcSliceMut with the given underlying buffer, returning it if an
allocation fails.
The buffer can be extracted back using try_into_buffer.
Having an Arc allocation depends on the layout and the buffer type,
e.g. there will be no allocation for a Vec with VecLayout.
§Examples
use arc_slice::{layout::ArcLayout, ArcSliceMut};
let s = ArcSliceMut::<[u8], ArcLayout<true>>::try_from_buffer(vec![0, 1, 2]).unwrap();
assert_eq!(s, [0, 1, 2]);
assert_eq!(s.try_into_buffer::<Vec<u8>>().unwrap(), vec![0, 1, 2]);Sourcepub fn from_buffer_with_metadata<B: BufferMut<S>, M: Send + Sync + 'static>(
buffer: B,
metadata: M,
) -> Self
Available on crate feature oom-handling only.
pub fn from_buffer_with_metadata<B: BufferMut<S>, M: Send + Sync + 'static>( buffer: B, metadata: M, ) -> Self
oom-handling only.Creates a new ArcSliceMut with the given underlying buffer and its associated metadata.
The buffer can be extracted back using try_into_buffer;
metadata can be retrieved with metadata.
§Examples
use arc_slice::{layout::ArcLayout, ArcSliceMut};
let metadata = "metadata".to_string();
let s =
ArcSliceMut::<[u8], ArcLayout<true>>::from_buffer_with_metadata(vec![0, 1, 2], metadata);
assert_eq!(s, [0, 1, 2]);
assert_eq!(s.metadata::<String>().unwrap(), "metadata");
assert_eq!(s.try_into_buffer::<Vec<u8>>().unwrap(), vec![0, 1, 2]);Sourcepub fn try_from_buffer_with_metadata<B: BufferMut<S>, M: Send + Sync + 'static>(
buffer: B,
metadata: M,
) -> Result<Self, (B, M)>
pub fn try_from_buffer_with_metadata<B: BufferMut<S>, M: Send + Sync + 'static>( buffer: B, metadata: M, ) -> Result<Self, (B, M)>
Tries creates a new ArcSliceMut with the given underlying buffer and its associated metadata,
returning them if an allocation fails.
The buffer can be extracted back using try_into_buffer;
metadata can be retrieved with metadata.
Having an Arc allocation depends on the layout and the buffer type,
e.g. there will be no allocation for a Vec with VecLayout.
§Examples
use arc_slice::{layout::ArcLayout, ArcSliceMut};
let metadata = "metadata".to_string();
let s = ArcSliceMut::<[u8], ArcLayout<true>>::try_from_buffer_with_metadata(
vec![0, 1, 2],
metadata,
)
.unwrap();
assert_eq!(s, [0, 1, 2]);
assert_eq!(s.metadata::<String>().unwrap(), "metadata");
assert_eq!(s.try_into_buffer::<Vec<u8>>().unwrap(), vec![0, 1, 2]);Sourcepub fn from_buffer_with_borrowed_metadata<B: BufferMut<S> + BorrowMetadata>(
buffer: B,
) -> Self
Available on crate feature oom-handling only.
pub fn from_buffer_with_borrowed_metadata<B: BufferMut<S> + BorrowMetadata>( buffer: B, ) -> Self
oom-handling only.Creates a new ArcSliceMut with the given underlying buffer with borrowed metadata.
The buffer can be extracted back using try_into_buffer;
metadata can be retrieved with metadata.
§Examples
use arc_slice::{
buffer::{BorrowMetadata, Buffer, BufferMut},
error::TryReserveError,
layout::ArcLayout,
ArcSliceMut,
};
#[derive(Debug, PartialEq, Eq)]
struct MyBuffer(Vec<u8>);
impl Buffer<[u8]> for MyBuffer {
fn as_slice(&self) -> &[u8] {
&self.0
}
}
#[derive(Debug, PartialEq, Eq)]
struct MyMetadata;
impl BorrowMetadata for MyBuffer {
type Metadata = MyMetadata;
fn borrow_metadata(&self) -> &Self::Metadata {
&MyMetadata
}
}
// SAFETY: `MyBuffer` delegates to `Vec<u8>`, which upholds the invariant
unsafe impl BufferMut<[u8]> for MyBuffer {
fn as_mut_slice(&mut self) -> &mut [u8] {
&mut self.0
}
fn capacity(&self) -> usize {
self.0.capacity()
}
unsafe fn set_len(&mut self, len: usize) -> bool {
// SAFETY: same function contract
unsafe { self.0.set_len(len) };
true
}
fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError> {
BufferMut::try_reserve(&mut self.0, additional)
}
}
let buffer = MyBuffer(vec![0, 1, 2]);
let s = ArcSliceMut::<[u8], ArcLayout<true>>::from_buffer_with_borrowed_metadata(buffer);
assert_eq!(s, [0, 1, 2]);
assert_eq!(s.metadata::<MyMetadata>().unwrap(), &MyMetadata);
assert_eq!(
s.try_into_buffer::<MyBuffer>().unwrap(),
MyBuffer(vec![0, 1, 2])
);Sourcepub fn try_from_buffer_with_borrowed_metadata<B: BufferMut<S> + BorrowMetadata>(
buffer: B,
) -> Result<Self, B>
pub fn try_from_buffer_with_borrowed_metadata<B: BufferMut<S> + BorrowMetadata>( buffer: B, ) -> Result<Self, B>
Tries creating a new ArcSliceMut with the given underlying buffer with borrowed metadata,
returning it if an allocation fails.
The buffer can be extracted back using try_into_buffer;
metadata can be retrieved with metadata.
Having an Arc allocation depends on the layout and the buffer type,
e.g. there will be no allocation for a Vec with VecLayout.
§Examples
use arc_slice::{
buffer::{BorrowMetadata, Buffer, BufferMut},
error::TryReserveError,
layout::ArcLayout,
ArcSliceMut,
};
#[derive(Debug, PartialEq, Eq)]
struct MyBuffer(Vec<u8>);
impl Buffer<[u8]> for MyBuffer {
fn as_slice(&self) -> &[u8] {
&self.0
}
}
// SAFETY: `MyBuffer` delegates to `Vec<u8>`, which upholds the invariant
unsafe impl BufferMut<[u8]> for MyBuffer {
fn as_mut_slice(&mut self) -> &mut [u8] {
&mut self.0
}
fn capacity(&self) -> usize {
self.0.capacity()
}
unsafe fn set_len(&mut self, len: usize) -> bool {
// SAFETY: same function contract
unsafe { self.0.set_len(len) };
true
}
fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError> {
BufferMut::try_reserve(&mut self.0, additional)
}
}
#[derive(Debug, PartialEq, Eq)]
struct MyMetadata;
impl BorrowMetadata for MyBuffer {
type Metadata = MyMetadata;
fn borrow_metadata(&self) -> &Self::Metadata {
&MyMetadata
}
}
let buffer = MyBuffer(vec![0, 1, 2]);
let s = ArcSliceMut::<[u8], ArcLayout<true>>::try_from_buffer_with_borrowed_metadata(buffer)
.unwrap();
assert_eq!(s, [0, 1, 2]);
assert_eq!(s.metadata::<MyMetadata>().unwrap(), &MyMetadata);
assert_eq!(
s.try_into_buffer::<MyBuffer>().unwrap(),
MyBuffer(vec![0, 1, 2])
);Trait Implementations§
Source§impl<S: Slice + ?Sized, L: LayoutMut, const UNIQUE: bool> AsMut<S> for ArcSliceMut<S, L, UNIQUE>
impl<S: Slice + ?Sized, L: LayoutMut, const UNIQUE: bool> AsMut<S> for ArcSliceMut<S, L, UNIQUE>
Source§impl<S: Slice + ?Sized, L: LayoutMut, const UNIQUE: bool> AsRef<S> for ArcSliceMut<S, L, UNIQUE>
impl<S: Slice + ?Sized, L: LayoutMut, const UNIQUE: bool> AsRef<S> for ArcSliceMut<S, L, UNIQUE>
Source§impl<S: Slice + ?Sized, L: LayoutMut, const UNIQUE: bool> Borrow<S> for ArcSliceMut<S, L, UNIQUE>
impl<S: Slice + ?Sized, L: LayoutMut, const UNIQUE: bool> Borrow<S> for ArcSliceMut<S, L, UNIQUE>
Source§impl<S: Slice + ?Sized, L: LayoutMut, const UNIQUE: bool> BorrowMut<S> for ArcSliceMut<S, L, UNIQUE>
impl<S: Slice + ?Sized, L: LayoutMut, const UNIQUE: bool> BorrowMut<S> for ArcSliceMut<S, L, UNIQUE>
Source§fn borrow_mut(&mut self) -> &mut S
fn borrow_mut(&mut self) -> &mut S
Source§impl<S: Slice<Item = u8> + Subsliceable + ?Sized, L: LayoutMut, const UNIQUE: bool> Buf for ArcSliceMut<S, L, UNIQUE>
Available on crate feature bytes only.
impl<S: Slice<Item = u8> + Subsliceable + ?Sized, L: LayoutMut, const UNIQUE: bool> Buf for ArcSliceMut<S, L, UNIQUE>
bytes only.Source§fn remaining(&self) -> usize
fn remaining(&self) -> usize
Source§fn chunk(&self) -> &[u8] ⓘ
fn chunk(&self) -> &[u8] ⓘ
Buf::remaining(). Note that this can return a shorter slice (this
allows non-continuous internal representation). Read moreSource§fn has_remaining(&self) -> bool
fn has_remaining(&self) -> bool
Source§fn copy_to_slice(&mut self, dst: &mut [u8])
fn copy_to_slice(&mut self, dst: &mut [u8])
Source§fn get_u16(&mut self) -> u16
fn get_u16(&mut self) -> u16
self in big-endian byte order. Read moreSource§fn get_u16_le(&mut self) -> u16
fn get_u16_le(&mut self) -> u16
self in little-endian byte order. Read moreSource§fn get_u16_ne(&mut self) -> u16
fn get_u16_ne(&mut self) -> u16
self in native-endian byte order. Read moreSource§fn get_i16(&mut self) -> i16
fn get_i16(&mut self) -> i16
self in big-endian byte order. Read moreSource§fn get_i16_le(&mut self) -> i16
fn get_i16_le(&mut self) -> i16
self in little-endian byte order. Read moreSource§fn get_i16_ne(&mut self) -> i16
fn get_i16_ne(&mut self) -> i16
self in native-endian byte order. Read moreSource§fn get_u32(&mut self) -> u32
fn get_u32(&mut self) -> u32
self in the big-endian byte order. Read moreSource§fn get_u32_le(&mut self) -> u32
fn get_u32_le(&mut self) -> u32
self in the little-endian byte order. Read moreSource§fn get_u32_ne(&mut self) -> u32
fn get_u32_ne(&mut self) -> u32
self in native-endian byte order. Read moreSource§fn get_i32(&mut self) -> i32
fn get_i32(&mut self) -> i32
self in big-endian byte order. Read moreSource§fn get_i32_le(&mut self) -> i32
fn get_i32_le(&mut self) -> i32
self in little-endian byte order. Read moreSource§fn get_i32_ne(&mut self) -> i32
fn get_i32_ne(&mut self) -> i32
self in native-endian byte order. Read moreSource§fn get_u64(&mut self) -> u64
fn get_u64(&mut self) -> u64
self in big-endian byte order. Read moreSource§fn get_u64_le(&mut self) -> u64
fn get_u64_le(&mut self) -> u64
self in little-endian byte order. Read moreSource§fn get_u64_ne(&mut self) -> u64
fn get_u64_ne(&mut self) -> u64
self in native-endian byte order. Read moreSource§fn get_i64(&mut self) -> i64
fn get_i64(&mut self) -> i64
self in big-endian byte order. Read moreSource§fn get_i64_le(&mut self) -> i64
fn get_i64_le(&mut self) -> i64
self in little-endian byte order. Read moreSource§fn get_i64_ne(&mut self) -> i64
fn get_i64_ne(&mut self) -> i64
self in native-endian byte order. Read moreSource§fn get_u128(&mut self) -> u128
fn get_u128(&mut self) -> u128
self in big-endian byte order. Read moreSource§fn get_u128_le(&mut self) -> u128
fn get_u128_le(&mut self) -> u128
self in little-endian byte order. Read moreSource§fn get_u128_ne(&mut self) -> u128
fn get_u128_ne(&mut self) -> u128
self in native-endian byte order. Read moreSource§fn get_i128(&mut self) -> i128
fn get_i128(&mut self) -> i128
self in big-endian byte order. Read moreSource§fn get_i128_le(&mut self) -> i128
fn get_i128_le(&mut self) -> i128
self in little-endian byte order. Read moreSource§fn get_i128_ne(&mut self) -> i128
fn get_i128_ne(&mut self) -> i128
self in native-endian byte order. Read moreSource§fn get_uint(&mut self, nbytes: usize) -> u64
fn get_uint(&mut self, nbytes: usize) -> u64
self in big-endian byte order. Read moreSource§fn get_uint_le(&mut self, nbytes: usize) -> u64
fn get_uint_le(&mut self, nbytes: usize) -> u64
self in little-endian byte order. Read moreSource§fn get_uint_ne(&mut self, nbytes: usize) -> u64
fn get_uint_ne(&mut self, nbytes: usize) -> u64
self in native-endian byte order. Read moreSource§fn get_int(&mut self, nbytes: usize) -> i64
fn get_int(&mut self, nbytes: usize) -> i64
self in big-endian byte order. Read moreSource§fn get_int_le(&mut self, nbytes: usize) -> i64
fn get_int_le(&mut self, nbytes: usize) -> i64
self in little-endian byte order. Read moreSource§fn get_int_ne(&mut self, nbytes: usize) -> i64
fn get_int_ne(&mut self, nbytes: usize) -> i64
self in native-endian byte order. Read moreSource§fn get_f32(&mut self) -> f32
fn get_f32(&mut self) -> f32
self in big-endian byte order. Read moreSource§fn get_f32_le(&mut self) -> f32
fn get_f32_le(&mut self) -> f32
self in little-endian byte order. Read moreSource§fn get_f32_ne(&mut self) -> f32
fn get_f32_ne(&mut self) -> f32
self in native-endian byte order. Read moreSource§fn get_f64(&mut self) -> f64
fn get_f64(&mut self) -> f64
self in big-endian byte order. Read moreSource§fn get_f64_le(&mut self) -> f64
fn get_f64_le(&mut self) -> f64
self in little-endian byte order. Read moreSource§fn get_f64_ne(&mut self) -> f64
fn get_f64_ne(&mut self) -> f64
self in native-endian byte order. Read moreSource§fn try_copy_to_slice(&mut self, dst: &mut [u8]) -> Result<(), TryGetError>
fn try_copy_to_slice(&mut self, dst: &mut [u8]) -> Result<(), TryGetError>
Source§fn try_get_u8(&mut self) -> Result<u8, TryGetError>
fn try_get_u8(&mut self) -> Result<u8, TryGetError>
self. Read moreSource§fn try_get_i8(&mut self) -> Result<i8, TryGetError>
fn try_get_i8(&mut self) -> Result<i8, TryGetError>
self. Read moreSource§fn try_get_u16(&mut self) -> Result<u16, TryGetError>
fn try_get_u16(&mut self) -> Result<u16, TryGetError>
self in big-endian byte order. Read moreSource§fn try_get_u16_le(&mut self) -> Result<u16, TryGetError>
fn try_get_u16_le(&mut self) -> Result<u16, TryGetError>
self in little-endian byte order. Read moreSource§fn try_get_u16_ne(&mut self) -> Result<u16, TryGetError>
fn try_get_u16_ne(&mut self) -> Result<u16, TryGetError>
self in native-endian byte order. Read moreSource§fn try_get_i16(&mut self) -> Result<i16, TryGetError>
fn try_get_i16(&mut self) -> Result<i16, TryGetError>
self in big-endian byte order. Read moreSource§fn try_get_i16_le(&mut self) -> Result<i16, TryGetError>
fn try_get_i16_le(&mut self) -> Result<i16, TryGetError>
self in little-endian byte order. Read moreSource§fn try_get_i16_ne(&mut self) -> Result<i16, TryGetError>
fn try_get_i16_ne(&mut self) -> Result<i16, TryGetError>
self in native-endian byte order. Read moreSource§fn try_get_u32(&mut self) -> Result<u32, TryGetError>
fn try_get_u32(&mut self) -> Result<u32, TryGetError>
self in big-endian byte order. Read moreSource§fn try_get_u32_le(&mut self) -> Result<u32, TryGetError>
fn try_get_u32_le(&mut self) -> Result<u32, TryGetError>
self in little-endian byte order. Read moreSource§fn try_get_u32_ne(&mut self) -> Result<u32, TryGetError>
fn try_get_u32_ne(&mut self) -> Result<u32, TryGetError>
self in native-endian byte order. Read moreSource§fn try_get_i32(&mut self) -> Result<i32, TryGetError>
fn try_get_i32(&mut self) -> Result<i32, TryGetError>
self in big-endian byte order. Read moreSource§fn try_get_i32_le(&mut self) -> Result<i32, TryGetError>
fn try_get_i32_le(&mut self) -> Result<i32, TryGetError>
self in little-endian byte order. Read moreSource§fn try_get_i32_ne(&mut self) -> Result<i32, TryGetError>
fn try_get_i32_ne(&mut self) -> Result<i32, TryGetError>
self in native-endian byte order. Read moreSource§fn try_get_u64(&mut self) -> Result<u64, TryGetError>
fn try_get_u64(&mut self) -> Result<u64, TryGetError>
self in big-endian byte order. Read moreSource§fn try_get_u64_le(&mut self) -> Result<u64, TryGetError>
fn try_get_u64_le(&mut self) -> Result<u64, TryGetError>
self in little-endian byte order. Read moreSource§fn try_get_u64_ne(&mut self) -> Result<u64, TryGetError>
fn try_get_u64_ne(&mut self) -> Result<u64, TryGetError>
self in native-endian byte order. Read moreSource§fn try_get_i64(&mut self) -> Result<i64, TryGetError>
fn try_get_i64(&mut self) -> Result<i64, TryGetError>
self in big-endian byte order. Read moreSource§fn try_get_i64_le(&mut self) -> Result<i64, TryGetError>
fn try_get_i64_le(&mut self) -> Result<i64, TryGetError>
self in little-endian byte order. Read moreSource§fn try_get_i64_ne(&mut self) -> Result<i64, TryGetError>
fn try_get_i64_ne(&mut self) -> Result<i64, TryGetError>
self in native-endian byte order. Read moreSource§fn try_get_u128(&mut self) -> Result<u128, TryGetError>
fn try_get_u128(&mut self) -> Result<u128, TryGetError>
self in big-endian byte order. Read moreSource§fn try_get_u128_le(&mut self) -> Result<u128, TryGetError>
fn try_get_u128_le(&mut self) -> Result<u128, TryGetError>
self in little-endian byte order. Read moreSource§fn try_get_u128_ne(&mut self) -> Result<u128, TryGetError>
fn try_get_u128_ne(&mut self) -> Result<u128, TryGetError>
self in native-endian byte order. Read moreSource§fn try_get_i128(&mut self) -> Result<i128, TryGetError>
fn try_get_i128(&mut self) -> Result<i128, TryGetError>
self in big-endian byte order. Read moreSource§fn try_get_i128_le(&mut self) -> Result<i128, TryGetError>
fn try_get_i128_le(&mut self) -> Result<i128, TryGetError>
self in little-endian byte order. Read moreSource§fn try_get_i128_ne(&mut self) -> Result<i128, TryGetError>
fn try_get_i128_ne(&mut self) -> Result<i128, TryGetError>
self in native-endian byte order. Read moreSource§fn try_get_uint(&mut self, nbytes: usize) -> Result<u64, TryGetError>
fn try_get_uint(&mut self, nbytes: usize) -> Result<u64, TryGetError>
self in big-endian byte order. Read moreSource§fn try_get_uint_le(&mut self, nbytes: usize) -> Result<u64, TryGetError>
fn try_get_uint_le(&mut self, nbytes: usize) -> Result<u64, TryGetError>
self in little-endian byte order. Read moreSource§fn try_get_uint_ne(&mut self, nbytes: usize) -> Result<u64, TryGetError>
fn try_get_uint_ne(&mut self, nbytes: usize) -> Result<u64, TryGetError>
self in native-endian byte order. Read moreSource§fn try_get_int(&mut self, nbytes: usize) -> Result<i64, TryGetError>
fn try_get_int(&mut self, nbytes: usize) -> Result<i64, TryGetError>
self in big-endian byte order. Read moreSource§fn try_get_int_le(&mut self, nbytes: usize) -> Result<i64, TryGetError>
fn try_get_int_le(&mut self, nbytes: usize) -> Result<i64, TryGetError>
self in little-endian byte order. Read moreSource§fn try_get_int_ne(&mut self, nbytes: usize) -> Result<i64, TryGetError>
fn try_get_int_ne(&mut self, nbytes: usize) -> Result<i64, TryGetError>
self in native-endian byte order. Read moreSource§fn try_get_f32(&mut self) -> Result<f32, TryGetError>
fn try_get_f32(&mut self) -> Result<f32, TryGetError>
self in big-endian byte order. Read moreSource§fn try_get_f32_le(&mut self) -> Result<f32, TryGetError>
fn try_get_f32_le(&mut self) -> Result<f32, TryGetError>
self in little-endian byte order. Read moreSource§fn try_get_f32_ne(&mut self) -> Result<f32, TryGetError>
fn try_get_f32_ne(&mut self) -> Result<f32, TryGetError>
self in native-endian byte order. Read moreSource§fn try_get_f64(&mut self) -> Result<f64, TryGetError>
fn try_get_f64(&mut self) -> Result<f64, TryGetError>
self in big-endian byte order. Read moreSource§fn try_get_f64_le(&mut self) -> Result<f64, TryGetError>
fn try_get_f64_le(&mut self) -> Result<f64, TryGetError>
self in little-endian byte order. Read moreSource§fn try_get_f64_ne(&mut self) -> Result<f64, TryGetError>
fn try_get_f64_ne(&mut self) -> Result<f64, TryGetError>
self in native-endian byte order. Read moreSource§fn copy_to_bytes(&mut self, len: usize) -> Bytes
fn copy_to_bytes(&mut self, len: usize) -> Bytes
Source§impl<S: Slice<Item = u8> + Extendable + ?Sized, L: LayoutMut, const UNIQUE: bool> BufMut for ArcSliceMut<S, L, UNIQUE>
Available on crate feature bytes only.
impl<S: Slice<Item = u8> + Extendable + ?Sized, L: LayoutMut, const UNIQUE: bool> BufMut for ArcSliceMut<S, L, UNIQUE>
bytes only.Source§fn remaining_mut(&self) -> usize
fn remaining_mut(&self) -> usize
Source§unsafe fn advance_mut(&mut self, cnt: usize)
unsafe fn advance_mut(&mut self, cnt: usize)
Source§fn chunk_mut(&mut self) -> &mut UninitSlice
fn chunk_mut(&mut self) -> &mut UninitSlice
BufMut::remaining_mut(). Note that this can be shorter than the
whole remainder of the buffer (this allows non-continuous implementation). Read moreSource§fn has_remaining_mut(&self) -> bool
fn has_remaining_mut(&self) -> bool
self for more bytes. Read moreSource§fn put_u16(&mut self, n: u16)
fn put_u16(&mut self, n: u16)
self in big-endian byte order. Read moreSource§fn put_u16_le(&mut self, n: u16)
fn put_u16_le(&mut self, n: u16)
self in little-endian byte order. Read moreSource§fn put_u16_ne(&mut self, n: u16)
fn put_u16_ne(&mut self, n: u16)
self in native-endian byte order. Read moreSource§fn put_i16(&mut self, n: i16)
fn put_i16(&mut self, n: i16)
self in big-endian byte order. Read moreSource§fn put_i16_le(&mut self, n: i16)
fn put_i16_le(&mut self, n: i16)
self in little-endian byte order. Read moreSource§fn put_i16_ne(&mut self, n: i16)
fn put_i16_ne(&mut self, n: i16)
self in native-endian byte order. Read moreSource§fn put_u32(&mut self, n: u32)
fn put_u32(&mut self, n: u32)
self in big-endian byte order. Read moreSource§fn put_u32_le(&mut self, n: u32)
fn put_u32_le(&mut self, n: u32)
self in little-endian byte order. Read moreSource§fn put_u32_ne(&mut self, n: u32)
fn put_u32_ne(&mut self, n: u32)
self in native-endian byte order. Read moreSource§fn put_i32(&mut self, n: i32)
fn put_i32(&mut self, n: i32)
self in big-endian byte order. Read moreSource§fn put_i32_le(&mut self, n: i32)
fn put_i32_le(&mut self, n: i32)
self in little-endian byte order. Read moreSource§fn put_i32_ne(&mut self, n: i32)
fn put_i32_ne(&mut self, n: i32)
self in native-endian byte order. Read moreSource§fn put_u64(&mut self, n: u64)
fn put_u64(&mut self, n: u64)
self in the big-endian byte order. Read moreSource§fn put_u64_le(&mut self, n: u64)
fn put_u64_le(&mut self, n: u64)
self in little-endian byte order. Read moreSource§fn put_u64_ne(&mut self, n: u64)
fn put_u64_ne(&mut self, n: u64)
self in native-endian byte order. Read moreSource§fn put_i64(&mut self, n: i64)
fn put_i64(&mut self, n: i64)
self in the big-endian byte order. Read moreSource§fn put_i64_le(&mut self, n: i64)
fn put_i64_le(&mut self, n: i64)
self in little-endian byte order. Read moreSource§fn put_i64_ne(&mut self, n: i64)
fn put_i64_ne(&mut self, n: i64)
self in native-endian byte order. Read moreSource§fn put_u128(&mut self, n: u128)
fn put_u128(&mut self, n: u128)
self in the big-endian byte order. Read moreSource§fn put_u128_le(&mut self, n: u128)
fn put_u128_le(&mut self, n: u128)
self in little-endian byte order. Read moreSource§fn put_u128_ne(&mut self, n: u128)
fn put_u128_ne(&mut self, n: u128)
self in native-endian byte order. Read moreSource§fn put_i128(&mut self, n: i128)
fn put_i128(&mut self, n: i128)
self in the big-endian byte order. Read moreSource§fn put_i128_le(&mut self, n: i128)
fn put_i128_le(&mut self, n: i128)
self in little-endian byte order. Read moreSource§fn put_i128_ne(&mut self, n: i128)
fn put_i128_ne(&mut self, n: i128)
self in native-endian byte order. Read moreSource§fn put_uint(&mut self, n: u64, nbytes: usize)
fn put_uint(&mut self, n: u64, nbytes: usize)
self in big-endian byte order. Read moreSource§fn put_uint_le(&mut self, n: u64, nbytes: usize)
fn put_uint_le(&mut self, n: u64, nbytes: usize)
self in the little-endian byte order. Read moreSource§fn put_uint_ne(&mut self, n: u64, nbytes: usize)
fn put_uint_ne(&mut self, n: u64, nbytes: usize)
self in the native-endian byte order. Read moreSource§fn put_int_le(&mut self, n: i64, nbytes: usize)
fn put_int_le(&mut self, n: i64, nbytes: usize)
Source§fn put_int_ne(&mut self, n: i64, nbytes: usize)
fn put_int_ne(&mut self, n: i64, nbytes: usize)
Source§fn put_f32(&mut self, n: f32)
fn put_f32(&mut self, n: f32)
self in big-endian byte order. Read moreSource§fn put_f32_le(&mut self, n: f32)
fn put_f32_le(&mut self, n: f32)
self in little-endian byte order. Read moreSource§fn put_f32_ne(&mut self, n: f32)
fn put_f32_ne(&mut self, n: f32)
self in native-endian byte order. Read moreSource§fn put_f64(&mut self, n: f64)
fn put_f64(&mut self, n: f64)
self in big-endian byte order. Read moreSource§fn put_f64_le(&mut self, n: f64)
fn put_f64_le(&mut self, n: f64)
self in little-endian byte order. Read moreSource§fn put_f64_ne(&mut self, n: f64)
fn put_f64_ne(&mut self, n: f64)
self in native-endian byte order. Read moreSource§impl<S: Debug + Slice + ?Sized, L: LayoutMut, const UNIQUE: bool> Debug for ArcSliceMut<S, L, UNIQUE>
impl<S: Debug + Slice + ?Sized, L: LayoutMut, const UNIQUE: bool> Debug for ArcSliceMut<S, L, UNIQUE>
Source§impl<S: Slice + ?Sized, L: LayoutMut, const UNIQUE: bool> Deref for ArcSliceMut<S, L, UNIQUE>
impl<S: Slice + ?Sized, L: LayoutMut, const UNIQUE: bool> Deref for ArcSliceMut<S, L, UNIQUE>
Source§impl<S: Slice + ?Sized, L: LayoutMut, const UNIQUE: bool> DerefMut for ArcSliceMut<S, L, UNIQUE>
impl<S: Slice + ?Sized, L: LayoutMut, const UNIQUE: bool> DerefMut for ArcSliceMut<S, L, UNIQUE>
Source§impl<'de, S: Slice + Deserializable + ?Sized, L: LayoutMut> Deserialize<'de> for ArcSliceMut<S, L>
Available on crate feature serde only.
impl<'de, S: Slice + Deserializable + ?Sized, L: LayoutMut> Deserialize<'de> for ArcSliceMut<S, L>
serde only.Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl<S: Display + Slice + ?Sized, L: LayoutMut, const UNIQUE: bool> Display for ArcSliceMut<S, L, UNIQUE>
impl<S: Display + Slice + ?Sized, L: LayoutMut, const UNIQUE: bool> Display for ArcSliceMut<S, L, UNIQUE>
Source§impl<S: Emptyable + Extendable + ?Sized, L: LayoutMut> Extend<<S as Slice>::Item> for ArcSliceMut<S, L>
Available on crate feature oom-handling only.
impl<S: Emptyable + Extendable + ?Sized, L: LayoutMut> Extend<<S as Slice>::Item> for ArcSliceMut<S, L>
oom-handling only.Source§fn extend<I: IntoIterator<Item = S::Item>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = S::Item>>(&mut self, iter: I)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl<T: Copy + Send + Sync + 'static, L: LayoutMut, const N: usize> From<&[T; N]> for ArcSliceMut<[T], L>
Available on crate feature oom-handling only.
impl<T: Copy + Send + Sync + 'static, L: LayoutMut, const N: usize> From<&[T; N]> for ArcSliceMut<[T], L>
oom-handling only.Source§impl<S: Slice + ?Sized, L: LayoutMut> From<&S> for ArcSliceMut<S, L>
Available on crate feature oom-handling only.
impl<S: Slice + ?Sized, L: LayoutMut> From<&S> for ArcSliceMut<S, L>
oom-handling only.Source§impl<T: Send + Sync + 'static, L: LayoutMut, const N: usize> From<[T; N]> for ArcSliceMut<[T], L>
Available on crate feature oom-handling only.
impl<T: Send + Sync + 'static, L: LayoutMut, const N: usize> From<[T; N]> for ArcSliceMut<[T], L>
oom-handling only.Source§impl<T: Send + Sync + 'static, L: AnyBufferLayout + LayoutMut> From<Vec<T>> for ArcSliceMut<[T], L>
Available on crate feature oom-handling only.
impl<T: Send + Sync + 'static, L: AnyBufferLayout + LayoutMut> From<Vec<T>> for ArcSliceMut<[T], L>
oom-handling only.Source§impl<S: Emptyable + Extendable + ?Sized, L: LayoutMut> FromIterator<<S as Slice>::Item> for ArcSliceMut<S, L>
Available on crate feature oom-handling only.
impl<S: Emptyable + Extendable + ?Sized, L: LayoutMut> FromIterator<<S as Slice>::Item> for ArcSliceMut<S, L>
oom-handling only.Source§impl<L: LayoutMut> FromStr for ArcSliceMut<str, L>
Available on crate feature oom-handling only.
impl<L: LayoutMut> FromStr for ArcSliceMut<str, L>
oom-handling only.Source§impl<S: Hash + Slice + ?Sized, L: LayoutMut, const UNIQUE: bool> Hash for ArcSliceMut<S, L, UNIQUE>
impl<S: Hash + Slice + ?Sized, L: LayoutMut, const UNIQUE: bool> Hash for ArcSliceMut<S, L, UNIQUE>
Source§impl<S: Slice<Item = u8> + ?Sized, L: LayoutMut, const UNIQUE: bool> LowerHex for ArcSliceMut<S, L, UNIQUE>
impl<S: Slice<Item = u8> + ?Sized, L: LayoutMut, const UNIQUE: bool> LowerHex for ArcSliceMut<S, L, UNIQUE>
Source§impl<S: Ord + Slice + ?Sized, L: LayoutMut, const UNIQUE: bool> Ord for ArcSliceMut<S, L, UNIQUE>
impl<S: Ord + Slice + ?Sized, L: LayoutMut, const UNIQUE: bool> Ord for ArcSliceMut<S, L, UNIQUE>
Source§fn cmp(&self, other: &ArcSliceMut<S, L, UNIQUE>) -> Ordering
fn cmp(&self, other: &ArcSliceMut<S, L, UNIQUE>) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<'a, T: PartialEq + Send + Sync + 'static, L: LayoutMut, const UNIQUE: bool, const N: usize> PartialEq<&'a [T; N]> for ArcSliceMut<[T], L, UNIQUE>
impl<'a, T: PartialEq + Send + Sync + 'static, L: LayoutMut, const UNIQUE: bool, const N: usize> PartialEq<&'a [T; N]> for ArcSliceMut<[T], L, UNIQUE>
Source§impl<'a, S: PartialEq + Slice + ?Sized, L: LayoutMut, const UNIQUE: bool> PartialEq<&'a S> for ArcSliceMut<S, L, UNIQUE>
impl<'a, S: PartialEq + Slice + ?Sized, L: LayoutMut, const UNIQUE: bool> PartialEq<&'a S> for ArcSliceMut<S, L, UNIQUE>
Source§impl<T: PartialEq + Send + Sync + 'static, L: LayoutMut, const UNIQUE: bool, const N: usize> PartialEq<[T; N]> for ArcSliceMut<[T], L, UNIQUE>
impl<T: PartialEq + Send + Sync + 'static, L: LayoutMut, const UNIQUE: bool, const N: usize> PartialEq<[T; N]> for ArcSliceMut<[T], L, UNIQUE>
Source§impl<T: PartialEq + Send + Sync + 'static, L: LayoutMut, const UNIQUE: bool> PartialEq<ArcSliceMut<[T], L, UNIQUE>> for [T]
impl<T: PartialEq + Send + Sync + 'static, L: LayoutMut, const UNIQUE: bool> PartialEq<ArcSliceMut<[T], L, UNIQUE>> for [T]
Source§impl<T: PartialEq + Send + Sync + 'static, L: LayoutMut, const UNIQUE: bool, const N: usize> PartialEq<ArcSliceMut<[T], L, UNIQUE>> for [T; N]
impl<T: PartialEq + Send + Sync + 'static, L: LayoutMut, const UNIQUE: bool, const N: usize> PartialEq<ArcSliceMut<[T], L, UNIQUE>> for [T; N]
Source§impl<T: PartialEq + Send + Sync + 'static, L: LayoutMut, const UNIQUE: bool> PartialEq<ArcSliceMut<[T], L, UNIQUE>> for Vec<T>
impl<T: PartialEq + Send + Sync + 'static, L: LayoutMut, const UNIQUE: bool> PartialEq<ArcSliceMut<[T], L, UNIQUE>> for Vec<T>
Source§impl<S: PartialEq + Slice + ?Sized, L: LayoutMut, const UNIQUE: bool> PartialEq<S> for ArcSliceMut<S, L, UNIQUE>
impl<S: PartialEq + Slice + ?Sized, L: LayoutMut, const UNIQUE: bool> PartialEq<S> for ArcSliceMut<S, L, UNIQUE>
Source§impl<T: PartialEq + Send + Sync + 'static, L: LayoutMut, const UNIQUE: bool> PartialEq<Vec<T>> for ArcSliceMut<[T], L, UNIQUE>
impl<T: PartialEq + Send + Sync + 'static, L: LayoutMut, const UNIQUE: bool> PartialEq<Vec<T>> for ArcSliceMut<[T], L, UNIQUE>
Source§impl<S: PartialEq + Slice + ?Sized, L: LayoutMut, const UNIQUE: bool> PartialEq for ArcSliceMut<S, L, UNIQUE>
impl<S: PartialEq + Slice + ?Sized, L: LayoutMut, const UNIQUE: bool> PartialEq for ArcSliceMut<S, L, UNIQUE>
Source§impl<S: PartialOrd + Slice + ?Sized, L: LayoutMut, const UNIQUE: bool> PartialOrd for ArcSliceMut<S, L, UNIQUE>
impl<S: PartialOrd + Slice + ?Sized, L: LayoutMut, const UNIQUE: bool> PartialOrd for ArcSliceMut<S, L, UNIQUE>
Source§impl<L: LayoutMut, const UNIQUE: bool> Read for ArcSliceMut<[u8], L, UNIQUE>
Available on crate feature std only.
impl<L: LayoutMut, const UNIQUE: bool> Read for ArcSliceMut<[u8], L, UNIQUE>
std only.Source§fn read(&mut self, buf: &mut [u8]) -> Result<usize>
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
1.36.0 · Source§fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
read, except that it reads into a slice of buffers. Read moreSource§fn is_read_vectored(&self) -> bool
fn is_read_vectored(&self) -> bool
can_vector)1.0.0 · Source§fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
buf. Read more1.0.0 · Source§fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
buf. Read more1.6.0 · Source§fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
buf. Read moreSource§fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
read_buf)Source§fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
read_buf)cursor. Read more1.0.0 · Source§fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
Read. Read moreSource§impl<S: Serialize + Slice + ?Sized, L: LayoutMut, const UNIQUE: bool> Serialize for ArcSliceMut<S, L, UNIQUE>
Available on crate feature serde only.
impl<S: Serialize + Slice + ?Sized, L: LayoutMut, const UNIQUE: bool> Serialize for ArcSliceMut<S, L, UNIQUE>
serde only.Source§impl<T: Send + Sync + 'static, L: LayoutMut, const N: usize, const UNIQUE: bool> TryFrom<ArcSliceMut<[T], L, UNIQUE>> for [T; N]
impl<T: Send + Sync + 'static, L: LayoutMut, const N: usize, const UNIQUE: bool> TryFrom<ArcSliceMut<[T], L, UNIQUE>> for [T; N]
Source§impl<S: Slice<Item = u8> + ?Sized, L: LayoutMut, const UNIQUE: bool> UpperHex for ArcSliceMut<S, L, UNIQUE>
impl<S: Slice<Item = u8> + ?Sized, L: LayoutMut, const UNIQUE: bool> UpperHex for ArcSliceMut<S, L, UNIQUE>
Source§impl<L: LayoutMut, const UNIQUE: bool> Write for ArcSliceMut<[u8], L, UNIQUE>
Available on crate feature std only.
impl<L: LayoutMut, const UNIQUE: bool> Write for ArcSliceMut<[u8], L, UNIQUE>
std only.Source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
Source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector)1.0.0 · Source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
Source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
write_all_vectored)Source§impl<S: Slice<Item = u8> + Extendable + ?Sized, L: LayoutMut, const UNIQUE: bool> Write for ArcSliceMut<S, L, UNIQUE>
impl<S: Slice<Item = u8> + Extendable + ?Sized, L: LayoutMut, const UNIQUE: bool> Write for ArcSliceMut<S, L, UNIQUE>
Source§impl<L: LayoutMut, const UNIQUE: bool> Write for ArcSliceMut<str, L, UNIQUE>
impl<L: LayoutMut, const UNIQUE: bool> Write for ArcSliceMut<str, L, UNIQUE>
impl<S: PartialEq + Slice + ?Sized, L: LayoutMut, const UNIQUE: bool> Eq for ArcSliceMut<S, L, UNIQUE>
impl<S: Slice + ?Sized, L: LayoutMut, const UNIQUE: bool> Send for ArcSliceMut<S, L, UNIQUE>
impl<S: Slice + ?Sized, L: AnyBufferLayout + LayoutMut, const UNIQUE: bool> Sync for ArcSliceMut<S, L, UNIQUE>
Auto Trait Implementations§
impl<S, L, const UNIQUE: bool> Freeze for ArcSliceMut<S, L, UNIQUE>where
S: ?Sized,
impl<S, L, const UNIQUE: bool> RefUnwindSafe for ArcSliceMut<S, L, UNIQUE>
impl<S, L, const UNIQUE: bool> Unpin for ArcSliceMut<S, L, UNIQUE>
impl<S, L, const UNIQUE: bool> UnwindSafe for ArcSliceMut<S, L, UNIQUE>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more