#[repr(C)]pub struct ArcSlice<S: Slice + ?Sized, L: Layout = DefaultLayout> { /* private fields */ }
Expand description
A thread-safe, cheaply cloneable and sliceable container.
ArcSlice<S>
is roughly equivalent to a (*const S, Arc<S>)
pair: a pointer into a shared
buffer and its associated reference-counted owner. This allows it to behave like a slice while
ensuring memory safety and shared ownership.
With the appropriate layout, ArcSlice
can wrap arbitrary buffers such as Vec, memory-mapped
files, etc. Arbitrary metadata can also be attached to the buffer for contextual or
domain-specific needs.
It is mainly intended to manipulate [u8]
/str
byte slices, to facilitate zero-copy
operations in network programming, hence the aliases ArcBytes
/ArcStr
. 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;
let mut mem = ArcSlice::<[u8]>::from(b"hello world");
let a = mem.subslice(0..5);
assert_eq!(a, b"hello");
let b = mem.split_to(6);
assert_eq!(mem, b"world");
assert_eq!(b, b"hello ");
With shared memory:
use std::{
fs::File,
path::{Path, PathBuf},
};
use arc_slice::{buffer::AsRefBuffer, layout::ArcLayout, ArcSlice};
use memmap2::Mmap;
let path = Path::new("README.md").to_owned();
let file = File::open(&path)?;
let mmap = unsafe { Mmap::map(&file)? };
let buffer = AsRefBuffer(mmap);
let bytes: ArcSlice<[u8], ArcLayout<true>> = ArcSlice::from_buffer_with_metadata(buffer, path);
assert!(bytes.starts_with(b"# arc-slice"));
assert_eq!(bytes.metadata::<PathBuf>().unwrap(), Path::new("README.md"));
Implementations§
Source§impl<S: Slice + ?Sized, L: Layout> ArcSlice<S, L>
impl<S: Slice + ?Sized, L: Layout> ArcSlice<S, L>
Sourcepub const fn new() -> Selfwhere
S: Emptyable,
L: StaticLayout,
pub const fn new() -> Selfwhere
S: Emptyable,
L: StaticLayout,
Creates a new empty ArcSlice
.
This operation doesn’t allocate; it is roughly equivalent to ArcSlice::from_static(&[])
.
§Examples
use arc_slice::{layout::ArcLayout, ArcSlice};
let s = ArcSlice::<[u8], ArcLayout<true, true>>::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 ArcSlice
by copying the given slice, returning an error if the
allocation fails.
§Examples
use arc_slice::ArcSlice;
let s = ArcSlice::<[u8]>::try_from_slice(b"hello world")?;
assert_eq!(s, b"hello world");
Sourcepub const fn len(&self) -> usize
pub const fn len(&self) -> usize
Returns the number of items in the slice.
§Examples
use arc_slice::ArcSlice;
let s = ArcSlice::<[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::ArcSlice;
let s = ArcSlice::<[u8]>::from(&[0, 1, 2]);
assert!(!s.is_empty());
let s = ArcSlice::<[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_slice(&self) -> &S
pub fn as_slice(&self) -> &S
Returns a reference to the underlying slice.
Equivalent to &self[..]
.
§Examples
use arc_slice::ArcSlice;
let s = ArcSlice::<[u8]>::from(b"hello world");
assert_eq!(s.as_slice(), b"hello world");
Sourcepub fn borrow(&self, range: impl RangeBounds<usize>) -> ArcSliceBorrow<'_, S, L>where
S: Subsliceable,
pub fn borrow(&self, range: impl RangeBounds<usize>) -> ArcSliceBorrow<'_, S, L>where
S: Subsliceable,
Returns a borrowed view of an ArcSlice
subslice with a given range.
See ArcSliceBorrow
documentation.
§Examples
use arc_slice::ArcSlice;
let s = ArcSlice::<[u8]>::from(b"hello world");
let borrow = s.borrow(..5);
assert_eq!(&borrow[..], b"hello");
let s2: ArcSlice<[u8]> = borrow.clone_arc();
Sourcepub fn borrow_from_ref(&self, subset: &S) -> ArcSliceBorrow<'_, S, L>where
S: Subsliceable,
pub fn borrow_from_ref(&self, subset: &S) -> ArcSliceBorrow<'_, S, L>where
S: Subsliceable,
Returns a borrowed view of an ArcSlice
subslice from a slice reference.
See ArcSliceBorrow
documentation.
§Examples
use arc_slice::ArcSlice;
let s = ArcSlice::<[u8]>::from(b"hello world");
let hello = &s[..5];
let borrow = s.borrow_from_ref(hello);
assert_eq!(&borrow[..], b"hello");
let s2: ArcSlice<[u8]> = borrow.clone_arc();
Sourcepub fn try_clone(&self) -> Result<Self, AllocError>
pub fn try_clone(&self) -> Result<Self, AllocError>
Tries cloning the ArcSlice
, returning an error if an allocation fails.
The operation may allocate. See CloneNoAllocLayout
documentation for cases where it does not.
§Examples
use arc_slice::ArcSlice;
let s = ArcSlice::<[u8]>::try_from_slice(b"hello world")?;
let s2 = s.try_clone()?;
assert_eq!(s2, b"hello world");
Sourcepub fn try_subslice(
&self,
range: impl RangeBounds<usize>,
) -> Result<Self, AllocError>where
S: Subsliceable,
pub fn try_subslice(
&self,
range: impl RangeBounds<usize>,
) -> Result<Self, AllocError>where
S: Subsliceable,
Tries extracting a subslice of an ArcSlice
with a given range, returning an error if an
allocation fails.
The operation may allocate. See CloneNoAllocLayout
documentation for cases where it does not.
§Examples
use arc_slice::ArcSlice;
let s = ArcSlice::<[u8]>::try_from_slice(b"hello world")?;
let s2 = s.try_subslice(..5)?;
assert_eq!(s2, b"hello");
Sourcepub fn try_subslice_from_ref(&self, subset: &S) -> Result<Self, AllocError>where
S: Subsliceable,
pub fn try_subslice_from_ref(&self, subset: &S) -> Result<Self, AllocError>where
S: Subsliceable,
Tries extracting a subslice of an ArcSlice
from a slice reference, returning an error
if an allocation fails.
The operation may allocate. See CloneNoAllocLayout
documentation for case where it does not.
§Examples
use arc_slice::ArcSlice;
let s = ArcSlice::<[u8]>::try_from_slice(b"hello world")?;
let hello = &s[..5];
let s2 = s.try_subslice_from_ref(hello)?;
assert_eq!(s2, b"hello");
Sourcepub fn advance(&mut self, offset: usize)where
S: Subsliceable,
pub fn advance(&mut self, offset: usize)where
S: Subsliceable,
Sourcepub fn try_truncate(&mut self, len: usize) -> Result<(), AllocError>where
S: Subsliceable,
pub fn try_truncate(&mut self, len: usize) -> Result<(), AllocError>where
S: Subsliceable,
Tries truncating the slice to the first len
items, returning an error if an
allocation fails.
If len
is greater than the slice length, this has no effect.
The operation may not allocate, see
TruncateNoAllocLayout
documentation.
use arc_slice::ArcSlice;
let mut s = ArcSlice::<[u8]>::from(b"hello world");
s.try_truncate(5)?;
assert_eq!(s, b"hello");
}
Sourcepub fn try_split_off(&mut self, at: usize) -> Result<Self, AllocError>where
S: Subsliceable,
pub fn try_split_off(&mut self, at: usize) -> Result<Self, AllocError>where
S: Subsliceable,
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 ArcSlice
contains elements [at, len)
. This operation does not touch the underlying buffer.
The operation may not allocate, see
CloneNoAllocLayout
documentation.
§Panics
Panics if at > self.len()
.
§Examples
use arc_slice::ArcSlice;
let mut a = ArcSlice::<[u8]>::from(b"hello world");
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>where
S: Subsliceable,
pub fn try_split_to(&mut self, at: usize) -> Result<Self, AllocError>where
S: Subsliceable,
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 ArcSlice
contains elements [0, at)
. This operation does not touch the underlying buffer.
The operation may not allocate, see
CloneNoAllocLayout
documentation.
§Panics
Panics if at > self.len()
.
§Examples
use arc_slice::ArcSlice;
let mut a = ArcSlice::<[u8]>::from(b"hello world");
let b = a.try_split_to(5)?;
assert_eq!(a, b" world");
assert_eq!(b, b"hello");
Sourcepub fn try_into_mut<L2: LayoutMut>(self) -> Result<ArcSliceMut<S, L2>, Self>
pub fn try_into_mut<L2: LayoutMut>(self) -> Result<ArcSliceMut<S, L2>, Self>
Tries to acquire the slice as mutable, returning an ArcSliceMut
on success.
There must be no other reference to the underlying buffer, and this one must be mutable
for the conversion to succeed. Otherwise, the original slice is returned. An ArcSlice
created from an array/slice or a vector is guaranteed to have a mutable buffer, as well
as one returned ArcSliceMut::freeze
.
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::DefaultLayoutMut, ArcSlice, ArcSliceMut};
let mut a = ArcSlice::<[u8]>::from(b"hello world");
let b = a.clone();
assert!(b.try_into_mut::<DefaultLayoutMut>().is_err());
// b has been dropped
let a_mut: ArcSliceMut<[u8]> = a.try_into_mut().unwrap();
Sourcepub fn is_unique(&self) -> bool
pub fn is_unique(&self) -> bool
Returns true
if this is the only reference to the underlying buffer, and if this one
is unique (see Buffer::is_unique
).
§Examples
use arc_slice::ArcSlice;
let s = ArcSlice::<[u8]>::from(b"hello world");
assert!(s.is_unique());
let s2 = s.clone();
assert!(!s.is_unique());
drop(s2);
assert!(s.is_unique());
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, ArcSlice};
let metadata = "metadata".to_string();
let s = ArcSlice::<[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: Buffer<S>>(self) -> Result<B, Self>
pub fn try_into_buffer<B: Buffer<S>>(self) -> Result<B, Self>
Tries downcasting the ArcSlice
to its underlying buffer.
§Examples
use arc_slice::{layout::ArcLayout, ArcSlice};
let s = ArcSlice::<[u8], ArcLayout<true>>::from(vec![0, 1, 2]);
assert_eq!(s.try_into_buffer::<Vec<u8>>().unwrap(), [0, 1, 2]);
Sourcepub fn try_with_layout<L2: Layout>(self) -> Result<ArcSlice<S, L2>, Self>
pub fn try_with_layout<L2: Layout>(self) -> Result<ArcSlice<S, L2>, Self>
Tries to replace the layout of the ArcSlice
, 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},
ArcSlice,
};
let a = ArcSlice::<[u8], BoxedSliceLayout>::from(vec![0, 1, 2]);
let b = a.try_with_layout::<VecLayout>().unwrap();
assert!(b.try_with_layout::<ArcLayout<false>>().is_err());
Sourcepub fn into_arc_slice(self) -> ArcSlice<[S::Item], L>
pub fn into_arc_slice(self) -> ArcSlice<[S::Item], L>
Converts an ArcSlice
into a primitive ArcSlice
.
§Examples
use arc_slice::ArcSlice;
let s = ArcSlice::<str>::from("hello world");
let bytes: ArcSlice<[u8]> = s.into_arc_slice();
assert_eq!(bytes, b"hello world");
Sourcepub fn try_from_arc_slice(
slice: ArcSlice<[S::Item], L>,
) -> Result<Self, (S::TryFromSliceError, ArcSlice<[S::Item], L>)>
pub fn try_from_arc_slice( slice: ArcSlice<[S::Item], L>, ) -> Result<Self, (S::TryFromSliceError, ArcSlice<[S::Item], L>)>
Tries converting an item slice into the given ArcSlice
.
The conversion uses Slice::try_from_slice
.
§Examples
use arc_slice::ArcSlice;
let utf8 = ArcSlice::<[u8]>::from(b"hello world");
let not_utf8 = ArcSlice::<[u8]>::from(b"\x80\x81");
assert!(ArcSlice::<str>::try_from_arc_slice(utf8).is_ok());
assert!(ArcSlice::<str>::try_from_arc_slice(not_utf8).is_err());
Sourcepub unsafe fn from_arc_slice_unchecked(slice: ArcSlice<[S::Item], L>) -> Self
pub unsafe fn from_arc_slice_unchecked(slice: ArcSlice<[S::Item], L>) -> Self
Converts an item slice into the given ArcSlice
, without checking the slice validity.
§Safety
The operation has the same contract as Slice::from_slice_unchecked
.
§Examples
use arc_slice::ArcSlice;
let utf8 = ArcSlice::<[u8]>::from(b"hello world");
// SAFETY: `utf8` is a valid utf8 string
let s = unsafe { ArcSlice::<str>::from_arc_slice_unchecked(utf8) };
assert_eq!(s, "hello world");
Sourcepub fn drop_with_unique_hint(self)
pub fn drop_with_unique_hint(self)
Drops an ArcSlice
, hinting that it should be unique.
In case of actual unicity, this method should be a little bit more efficient than a conventional drop. Indeed, in the case where an Arc has been allocated, it will first check the refcount, and shortcut the atomic fetch-and-sub if the count is one.
Source§impl<T: Send + Sync + 'static, L: Layout> ArcSlice<[T], L>
impl<T: Send + Sync + 'static, L: Layout> ArcSlice<[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.Source§impl<S: Slice + ?Sized, L: Layout> ArcSlice<S, L>
impl<S: Slice + ?Sized, L: Layout> ArcSlice<S, L>
Sourcepub fn truncate(&mut self, len: usize)where
S: Subsliceable,
pub fn truncate(&mut self, len: usize)where
S: Subsliceable,
Truncate the slice to the first len
items.
If len
is greater than the slice length, this has no effect.
use arc_slice::ArcSlice;
let mut s = ArcSlice::<[u8]>::from(b"hello world");
s.truncate(5);
assert_eq!(s, b"hello");
Source§impl<S: Slice + ?Sized, L: Layout> ArcSlice<S, L>
impl<S: Slice + ?Sized, L: Layout> ArcSlice<S, L>
Sourcepub fn subslice(&self, range: impl RangeBounds<usize>) -> Selfwhere
S: Subsliceable,
pub fn subslice(&self, range: impl RangeBounds<usize>) -> Selfwhere
S: Subsliceable,
Extracts a subslice of an ArcSlice
with a given range.
§Examples
use arc_slice::ArcSlice;
let s = ArcSlice::<[u8]>::from(b"hello world");
let s2 = s.subslice(..5);
assert_eq!(s2, b"hello");
Sourcepub fn subslice_from_ref(&self, subset: &S) -> Selfwhere
S: Subsliceable,
pub fn subslice_from_ref(&self, subset: &S) -> Selfwhere
S: Subsliceable,
Extracts a subslice of an ArcSlice
from a slice reference.
§Examples
use arc_slice::ArcSlice;
let s = ArcSlice::<[u8]>::from(b"hello world");
let hello = &s[..5];
let s2 = s.subslice_from_ref(hello);
assert_eq!(s2, b"hello");
Sourcepub fn split_off(&mut self, at: usize) -> Selfwhere
S: Subsliceable,
pub fn split_off(&mut self, at: usize) -> Selfwhere
S: Subsliceable,
Splits the slice into two at the given index.
Afterwards self
contains elements [0, at)
, and the returned ArcSlice
contains elements [at, len)
. This operation does not touch the underlying buffer.
§Panics
Panics if at > self.len()
.
§Examples
use arc_slice::ArcSlice;
let mut a = ArcSlice::<[u8]>::from(b"hello world");
let b = a.split_off(5);
assert_eq!(a, b"hello");
assert_eq!(b, b" world");
Sourcepub fn split_to(&mut self, at: usize) -> Selfwhere
S: Subsliceable,
pub fn split_to(&mut self, at: usize) -> Selfwhere
S: Subsliceable,
Splits the slice into two at the given index.
Afterwards self
contains elements [at, len)
, and the returned ArcSlice
contains elements [0, at)
. This operation does not touch the underlying buffer.
§Panics
Panics if at > self.len()
.
§Examples
use arc_slice::ArcSlice;
let mut a = ArcSlice::<[u8]>::from(b"hello world");
let b = a.split_to(5);
assert_eq!(a, b" world");
assert_eq!(b, b"hello");
Source§impl<S: Slice + ?Sized, L: Layout> ArcSlice<S, L>
impl<S: Slice + ?Sized, L: Layout> ArcSlice<S, L>
Sourcepub fn with_layout<L2: FromLayout<L>>(self) -> ArcSlice<S, L2>
Available on crate feature oom-handling
only.
pub fn with_layout<L2: FromLayout<L>>(self) -> ArcSlice<S, L2>
oom-handling
only.Replace the layout of the ArcSlice
.
The layouts must be compatible, see FromLayout
.
§Examples
use arc_slice::{
layout::{ArcLayout, BoxedSliceLayout, VecLayout},
ArcSlice,
};
let a = ArcSlice::<[u8]>::from(b"hello world");
let b = a.with_layout::<VecLayout>();
Source§impl<S: Slice + ?Sized, L: AnyBufferLayout> ArcSlice<S, L>
impl<S: Slice + ?Sized, L: AnyBufferLayout> ArcSlice<S, L>
Sourcepub fn from_buffer<B: Buffer<S>>(buffer: B) -> Self
Available on crate feature oom-handling
only.
pub fn from_buffer<B: Buffer<S>>(buffer: B) -> Self
oom-handling
only.Creates a new ArcSlice
with the given underlying buffer.
The buffer can be extracted back using try_into_buffer
.
§Examples
use arc_slice::{layout::ArcLayout, ArcSlice};
let s = ArcSlice::<[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: Buffer<S>>(buffer: B) -> Result<Self, B>
pub fn try_from_buffer<B: Buffer<S>>(buffer: B) -> Result<Self, B>
Tries creating a new ArcSlice
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, ArcSlice};
let s = ArcSlice::<[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: Buffer<S>, M: Send + Sync + 'static>(
buffer: B,
metadata: M,
) -> Self
Available on crate feature oom-handling
only.
pub fn from_buffer_with_metadata<B: Buffer<S>, M: Send + Sync + 'static>( buffer: B, metadata: M, ) -> Self
oom-handling
only.Creates a new ArcSlice
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, ArcSlice};
let metadata = "metadata".to_string();
let s = ArcSlice::<[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: Buffer<S>, M: Send + Sync + 'static>(
buffer: B,
metadata: M,
) -> Result<Self, (B, M)>
pub fn try_from_buffer_with_metadata<B: Buffer<S>, M: Send + Sync + 'static>( buffer: B, metadata: M, ) -> Result<Self, (B, M)>
Tries creates a new ArcSlice
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, ArcSlice};
let metadata = "metadata".to_string();
let s =
ArcSlice::<[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: Buffer<S> + BorrowMetadata>(
buffer: B,
) -> Self
Available on crate feature oom-handling
only.
pub fn from_buffer_with_borrowed_metadata<B: Buffer<S> + BorrowMetadata>( buffer: B, ) -> Self
oom-handling
only.Creates a new ArcSlice
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},
layout::ArcLayout,
ArcSlice,
};
#[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
}
}
let buffer = MyBuffer(vec![0, 1, 2]);
let s = ArcSlice::<[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: Buffer<S> + BorrowMetadata>(
buffer: B,
) -> Result<Self, B>
pub fn try_from_buffer_with_borrowed_metadata<B: Buffer<S> + BorrowMetadata>( buffer: B, ) -> Result<Self, B>
Tries creating a new ArcSlice
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},
layout::ArcLayout,
ArcSlice,
};
#[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
}
}
let buffer = MyBuffer(vec![0, 1, 2]);
let s =
ArcSlice::<[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])
);
Sourcepub fn from_raw_buffer<B: RawBuffer<S>>(buffer: B) -> Self
Available on crate features raw-buffer
and oom-handling
only.
pub fn from_raw_buffer<B: RawBuffer<S>>(buffer: B) -> Self
raw-buffer
and oom-handling
only.Creates a new ArcSlice
with the given underlying raw buffer.
For layouts others than RawLayout
, it is
the same as from_buffer
.
The buffer can be extracted back using try_into_buffer
.
§Examples
use std::sync::Arc;
use arc_slice::{layout::RawLayout, ArcSlice};
let s = ArcSlice::<[u8], RawLayout>::from_raw_buffer(Arc::new(vec![0, 1, 2]));
assert_eq!(s, [0, 1, 2]);
assert_eq!(
s.try_into_buffer::<Arc<Vec<u8>>>().unwrap(),
Arc::new(vec![0, 1, 2])
);
Sourcepub fn try_from_raw_buffer<B: RawBuffer<S>>(buffer: B) -> Result<Self, B>
Available on crate feature raw-buffer
only.
pub fn try_from_raw_buffer<B: RawBuffer<S>>(buffer: B) -> Result<Self, B>
raw-buffer
only.Tries creating a new ArcSlice
with the given underlying raw buffer, returning it if an
allocation fails.
For layouts others than RawLayout
, it is
the same as try_from_buffer
.
The buffer can be extracted back using try_into_buffer
.
§Examples
use std::sync::Arc;
use arc_slice::{layout::RawLayout, ArcSlice};
let s = ArcSlice::<[u8], RawLayout>::try_from_raw_buffer(Arc::new(vec![0, 1, 2])).unwrap();
assert_eq!(s, [0, 1, 2]);
assert_eq!(
s.try_into_buffer::<Arc<Vec<u8>>>().unwrap(),
Arc::new(vec![0, 1, 2])
);
Sourcepub fn from_raw_buffer_with_borrowed_metadata<B: RawBuffer<S> + BorrowMetadata>(
buffer: B,
) -> Self
Available on crate features raw-buffer
and oom-handling
only.
pub fn from_raw_buffer_with_borrowed_metadata<B: RawBuffer<S> + BorrowMetadata>( buffer: B, ) -> Self
raw-buffer
and oom-handling
only.Creates a new ArcSlice
with the given underlying raw buffer with borrowed metadata.
For layouts others than RawLayout
, it is
the same as from_buffer
.
The buffer can be extracted back using try_into_buffer
;
metadata can be retrieved with metadata
.
§Examples
use std::sync::Arc;
///
use arc_slice::buffer::{BorrowMetadata, Buffer};
use arc_slice::{layout::RawLayout, ArcSlice};
#[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
}
}
let buffer = Arc::new(MyBuffer(vec![0, 1, 2]));
let s = ArcSlice::<[u8], RawLayout>::from_raw_buffer_with_borrowed_metadata(buffer);
assert_eq!(s, [0, 1, 2]);
assert_eq!(s.metadata::<MyMetadata>().unwrap(), &MyMetadata);
assert_eq!(
s.try_into_buffer::<Arc<MyBuffer>>().unwrap(),
Arc::new(MyBuffer(vec![0, 1, 2]))
);
Sourcepub fn try_from_raw_buffer_with_borrowed_metadata<B: RawBuffer<S> + BorrowMetadata>(
buffer: B,
) -> Result<Self, B>
Available on crate feature raw-buffer
only.
pub fn try_from_raw_buffer_with_borrowed_metadata<B: RawBuffer<S> + BorrowMetadata>( buffer: B, ) -> Result<Self, B>
raw-buffer
only.Tries creating a new ArcSlice
with the given underlying raw buffer with borrowed metadata,
returning it if an allocation fails.
For layouts others than RawLayout
, it is
the same as from_buffer
.
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 std::sync::Arc;
///
use arc_slice::buffer::{BorrowMetadata, Buffer};
use arc_slice::{layout::RawLayout, ArcSlice};
#[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
}
}
let buffer = Arc::new(MyBuffer(vec![0, 1, 2]));
let s =
ArcSlice::<[u8], RawLayout>::try_from_raw_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::<Arc<MyBuffer>>().unwrap(),
Arc::new(MyBuffer(vec![0, 1, 2]))
);
Source§impl<L: StaticLayout> ArcSlice<[u8], L>
impl<L: StaticLayout> ArcSlice<[u8], L>
Sourcepub const fn from_static(slice: &'static [u8]) -> Self
pub const fn from_static(slice: &'static [u8]) -> Self
Creates a new ArcSlice
from a static slice.
The operation never allocates.
§Examples
use arc_slice::{layout::ArcLayout, ArcSlice};
static HELLO_WORLD: ArcSlice<[u8], ArcLayout<true, true>> =
ArcSlice::<[u8], ArcLayout<true, true>>::from_static(b"hello world");
Source§impl<L: StaticLayout> ArcSlice<str, L>
impl<L: StaticLayout> ArcSlice<str, L>
Sourcepub const fn from_static(slice: &'static str) -> Self
pub const fn from_static(slice: &'static str) -> Self
Creates a new ArcSlice
from a static str.
The operation never allocates.
§Examples
use arc_slice::{layout::ArcLayout, ArcSlice};
static HELLO_WORLD: ArcSlice<str, ArcLayout<true, true>> =
ArcSlice::<str, ArcLayout<true, true>>::from_static("hello world");
Trait Implementations§
Source§impl<S: Slice<Item = u8> + Subsliceable + ?Sized, L: Layout> Buf for ArcSlice<S, L>
Available on crate feature bytes
only.
impl<S: Slice<Item = u8> + Subsliceable + ?Sized, L: Layout> Buf for ArcSlice<S, L>
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<'de, S: Slice + Deserializable + ?Sized, L: Layout> Deserialize<'de> for ArcSlice<S, L>
Available on crate feature serde
only.
impl<'de, S: Slice + Deserializable + ?Sized, L: Layout> Deserialize<'de> for ArcSlice<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<T: Copy + Send + Sync + 'static, L: Layout, const N: usize> From<&[T; N]> for ArcSlice<[T], L>
Available on crate feature oom-handling
only.
impl<T: Copy + Send + Sync + 'static, L: Layout, const N: usize> From<&[T; N]> for ArcSlice<[T], L>
oom-handling
only.Source§impl<S: Slice + ?Sized, L: Layout> From<&S> for ArcSlice<S, L>
Available on crate feature oom-handling
only.
impl<S: Slice + ?Sized, L: Layout> From<&S> for ArcSlice<S, L>
oom-handling
only.Source§impl<T: Send + Sync + 'static, L: Layout, const N: usize> From<[T; N]> for ArcSlice<[T], L>
Available on crate feature oom-handling
only.
impl<T: Send + Sync + 'static, L: Layout, const N: usize> From<[T; N]> for ArcSlice<[T], L>
oom-handling
only.Source§impl<S: Slice<Item = u8> + ?Sized, L: Layout> From<ArcSlice<S, L>> for SmallArcSlice<S, L>
Available on crate feature inlined
only.
impl<S: Slice<Item = u8> + ?Sized, L: Layout> From<ArcSlice<S, L>> for SmallArcSlice<S, L>
inlined
only.Source§impl<S: Slice + ?Sized, L: AnyBufferLayout> From<Box<S>> for ArcSlice<S, L>
Available on crate feature oom-handling
only.
impl<S: Slice + ?Sized, L: AnyBufferLayout> From<Box<S>> for ArcSlice<S, L>
oom-handling
only.Source§impl<L: AnyBufferLayout> From<String> for ArcSlice<str, L>
Available on crate feature oom-handling
only.
impl<L: AnyBufferLayout> From<String> for ArcSlice<str, L>
oom-handling
only.Source§impl<T: Send + Sync + 'static, L: AnyBufferLayout> From<Vec<T>> for ArcSlice<[T], L>
Available on crate feature oom-handling
only.
impl<T: Send + Sync + 'static, L: AnyBufferLayout> From<Vec<T>> for ArcSlice<[T], L>
oom-handling
only.Source§impl<S: Ord + Slice + ?Sized, L: Layout> Ord for ArcSlice<S, L>
impl<S: Ord + Slice + ?Sized, L: Layout> Ord for ArcSlice<S, L>
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: Layout, const N: usize> PartialEq<&'a [T; N]> for ArcSlice<[T], L>
impl<'a, T: PartialEq + Send + Sync + 'static, L: Layout, const N: usize> PartialEq<&'a [T; N]> for ArcSlice<[T], L>
Source§impl<T: PartialEq + Send + Sync + 'static, L: Layout, const N: usize> PartialEq<[T; N]> for ArcSlice<[T], L>
impl<T: PartialEq + Send + Sync + 'static, L: Layout, const N: usize> PartialEq<[T; N]> for ArcSlice<[T], L>
Source§impl<T: PartialEq + Send + Sync + 'static, L: Layout, const N: usize> PartialEq<ArcSlice<[T], L>> for [T; N]
impl<T: PartialEq + Send + Sync + 'static, L: Layout, const N: usize> PartialEq<ArcSlice<[T], L>> for [T; N]
Source§impl<S: PartialOrd + Slice + ?Sized, L: Layout> PartialOrd for ArcSlice<S, L>
impl<S: PartialOrd + Slice + ?Sized, L: Layout> PartialOrd for ArcSlice<S, L>
Source§impl<L: Layout> Read for ArcSlice<[u8], L>
Available on crate feature std
only.
impl<L: Layout> Read for ArcSlice<[u8], L>
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: Layout> Serialize for ArcSlice<S, L>
Available on crate feature serde
only.
impl<S: Serialize + Slice + ?Sized, L: Layout> Serialize for ArcSlice<S, L>
serde
only.Source§impl<T: Send + Sync + 'static, L: Layout, const N: usize> TryFrom<ArcSlice<[T], L>> for [T; N]
impl<T: Send + Sync + 'static, L: Layout, const N: usize> TryFrom<ArcSlice<[T], L>> for [T; N]
impl<S: PartialEq + Slice + ?Sized, L: Layout> Eq for ArcSlice<S, L>
impl<S: Slice + ?Sized, L: Layout> Send for ArcSlice<S, L>
impl<S: Slice + ?Sized, L: Layout> Sync for ArcSlice<S, L>
Auto Trait Implementations§
impl<S, L> Freeze for ArcSlice<S, L>
impl<S, L> RefUnwindSafe for ArcSlice<S, L>
impl<S, L> Unpin for ArcSlice<S, L>
impl<S, L> UnwindSafe for ArcSlice<S, L>
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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