Handle

Struct Handle 

Source
pub struct Handle<'a, T: ?Sized> { /* private fields */ }
Expand description

An owned, mutable pointer to some memory backed by an Arena, analogous to Box<T>.

See the module documentation for more information.

Implementations§

Source§

impl<'a, T> Handle<'a, T>

Source

pub fn new_in<A: Allocator>(arena: &'a Arena<A>, value: T) -> Self

Create a new Handle containing the given value.

§Example
use rotunda::{Arena, handle::Handle};

let arena = Arena::new();
let handle = Handle::new_in(&arena, 156);
Source

pub fn new_with<A: Allocator, F: FnOnce() -> T>( arena: &'a Arena<A>, f: F, ) -> Self

Create a new Handle containing the return value of the given function.

§Example
use rotunda::{Arena, handle::Handle};

let arena = Arena::new();
let handle = Handle::new_with(&arena, || 23 + 45);
Source

pub unsafe fn init_with<A: Allocator, F: FnOnce(&mut MaybeUninit<T>)>( arena: &'a Arena<A>, f: F, ) -> Self

Create a new Handle, using the given function to initialize its contents.

§Safety

The function must fully initialize the allocated value, as this function will assume that the value has been fully initialized when the given f is run.

If this contract is not held, then this Handle may permit access to uninitialized data.

§Examples
use core::ptr::{self, addr_of_mut};
use rotunda::{Arena, handle::Handle};

struct Data {
    integer: u32,
    string: &'static str,
}

let arena = Arena::new();
let handle: Handle<'_, Data> = unsafe {
    Handle::init_with(&arena, |data| unsafe {
        let data_ptr: *mut Data = data.as_mut_ptr();
        ptr::write(addr_of_mut!((*data_ptr).integer), 25);
        ptr::write(addr_of_mut!((*data_ptr).string), "Default Data");
    })
};

assert_eq!(handle.integer, 25);
assert_eq!(handle.string, "Default Data");
Source

pub const fn into_slice(this: Self) -> Handle<'a, [T]>

Converts the handle into a Handle<[T]> with a slice length of 1.

§Examples
use rotunda::{Arena, handle::Handle};

let arena = Arena::new();
let handle = Handle::new_in(&arena, 'c');
let slice_handle = Handle::into_slice(handle);
assert_eq!(&*slice_handle, &['c']);
Source

pub const fn into_array(this: Self) -> Handle<'a, [T; 1]>

Converts the handle into a Handle<[T; 1]>.

§Examples
use rotunda::{Arena, handle::Handle};

let arena = Arena::new();
let handle = Handle::new_in(&arena, 266);

let array_handle = Handle::into_array(handle);
assert_eq!(array_handle, [266; 1]);
Source§

impl<'a, T> Handle<'a, [T; 1]>

Source

pub const fn from_array(this: Self) -> Handle<'a, T>

Create a Handle<T> from a handle to an array containing a single element.

§Examples
use rotunda::{Arena, handle::Handle};

let arena = Arena::new();
let array_handle = Handle::new_in(&arena, [25; 1]);

let handle = Handle::from_array(array_handle);
assert_eq!(handle, 25);
Source§

impl<'a, T: Default> Handle<'a, T>

Source

pub fn new_default_in<A: Allocator>(arena: &'a Arena<A>) -> Self

Create a new Handle in arena, containing the default value of T.

§Example
let arena = Arena::new();
let handle = Handle::<Vec<i32>>::new_default_in(&arena);
assert_eq!(&*handle, &<Vec<i32>>::default());
Source§

impl<'a, T> Handle<'a, MaybeUninit<T>>

Source

pub fn new_uninit_in<A: Allocator>(arena: &'a Arena<A>) -> Self

Create a new Handle in arena, containing an uninitialized MaybeUninit<T>.

§Examples
let arena = Arena::new();

let handle: Handle<MaybeUninit<i32>> = Handle::new_uninit_in(&arena);
Source

pub fn new_uninit_zeroed_in<A: Allocator>(arena: &'a Arena<A>) -> Self

Create a new Handle in arena, containing a zeroed MaybeUninit<T>.

§Examples
let arena = Arena::new();

let handle: Handle<MaybeUninit<i32>> = Handle::new_uninit_zeroed_in(&arena);
Source§

impl<'a, T, const N: usize> Handle<'a, [MaybeUninit<T>; N]>

Source

pub fn new_array_uninit_in<A: Allocator>(arena: &'a Arena<A>) -> Self

Source

pub fn new_array_uninit_zeroed_in<A: Allocator>(arena: &'a Arena<A>) -> Self

Source§

impl<'a, T> Handle<'a, [MaybeUninit<T>]>

Source

pub fn new_slice_uninit_in<A: Allocator>( arena: &'a Arena<A>, slice_len: usize, ) -> Self

Source§

impl<'a, T, const N: usize> Handle<'a, [T; N]>

Source

pub fn new_array_from_fn_in<A: Allocator, F: FnMut(usize) -> T>( arena: &'a Arena<A>, f: F, ) -> Self

Create a new Handle array.

Source§

impl<'a, T, const N: usize> Handle<'a, MaybeUninit<[T; N]>>

Source§

impl<'a, T, const N: usize> Handle<'a, [MaybeUninit<T>; N]>

Source

pub fn transpose_outer_uninit(self) -> Handle<'a, MaybeUninit<[T; N]>>

Source

pub const unsafe fn assume_init_array(self) -> Handle<'a, [T; N]>

Source§

impl<'a, T: ?Sized> Handle<'a, T>

Source

pub const fn into_raw(this: Self) -> *mut T

Converts the Handle into a raw pointer.

§Notes

Ownership of the resource managed by the Handle is transferred to the caller. It is their responsibility to ensure that the contents of the pointer are dropped when necessary.

Handle has no drop logic - it is valid to use either Handle::from_raw or core::ptr::drop_in_place to clean up the resource.

The pointer returned by Handle should not be accessed if the memory backing it in the Arena is dellocated.

§Examples
use rotunda::{Arena, handle::Handle};

let arena = Arena::new();
let handle = Handle::new_in(&arena, 42);

let ptr = Handle::into_raw(handle);
Source

pub const unsafe fn from_raw(raw: *mut T) -> Self

Take ownership of the given raw pointer.

§Safety

It is the caller’s responsibiity to ensure that raw has been created from a previous call to Handle::into_raw, and that the Arena backing it’s allocation has not cleared the block in use by the allocation.

If this precondition is not held, then the Handle may point to dangling memory.

use rotunda::{Arena, handle::Handle};

let arena = Arena::new();
let handle = Handle::new_in(&arena, 42u8);

let raw = Handle::into_raw(handle);

unsafe {
    *&mut (*raw) = 255;
}

let handle = unsafe { Handle::from_raw(raw) };
assert_eq!(handle, 255);
Source

pub const fn as_ptr(this: &Self) -> *const T

Access the contained value through a const pointer.

§Examples
use rotunda::{Arena, handle::Handle};

let arena = Arena::new();
let handle = Handle::new_in(&arena, 42);

let ptr = Handle::as_ptr(&handle);
Source

pub const fn as_mut_ptr(this: &mut Self) -> *mut T

Access the contained value through a mutable pointer.

§Examples
use rotunda::{Arena, handle::Handle};

let arena = Arena::new();
let mut handle = Handle::new_in(&arena, 42);

let ptr = Handle::as_mut_ptr(&mut handle);
Source

pub const fn into_pin(this: Self) -> Pin<Self>

Wrap the Handle in a Pin.

§Examples
use rotunda::{Arena, handle::Handle};

let arena = Arena::new();
let handle = Handle::new_in(&arena, 42);

let pinned = Handle::into_pin(handle);
Source§

impl<'a, T: Unpin> Handle<'a, T>

Source

pub const fn into_inner(this: Self) -> T

Returns the inner value of the Handle.

§Examples
use rotunda::{Arena, handle::Handle};

let arena = Arena::new();

let handle = Handle::new_in(&arena, vec![1, 2, 3, 4]);

let data = Handle::into_inner(handle);
assert_eq!(&data, &[1, 2, 3, 4]);
Source

pub const fn extract_inner(this: Self) -> (T, Handle<'a, MaybeUninit<T>>)

Extracts the inner value of the Handle, returning the value and the empty Handle.

§Examples
use rotunda::{Arena, handle::Handle};

let arena = Arena::new();

let mut handle = Handle::new_in(&arena, 1024);
let (data, empty_handle) = Handle::extract_inner(handle);

assert_eq!(data, 1024);

let new_handle = Handle::init(empty_handle, 2048);
Source

pub const fn replace(this: &mut Self, value: T) -> T

Replace the contents of this Handle with the given value.

The previous contents of the Handle are returned.

§Examples
use rotunda::{Arena, handle::Handle};

let arena = Arena::new();

let mut handle = Handle::new_in(&arena, 25);
let prev = Handle::replace(&mut handle, 42);

assert_eq!(*handle, 42);
assert_eq!(prev, 25);
Source§

impl<'a> Handle<'a, dyn Any>

Source

pub fn downcast<T: Any>(self) -> Result<Handle<'a, T>, Handle<'a, dyn Any>>

Source

pub unsafe fn downcast_unchecked<T: Any>(self) -> Handle<'a, T>

Source§

impl<'a> Handle<'a, dyn Any + Send>

Source

pub fn downcast<T: Any>( self, ) -> Result<Handle<'a, T>, Handle<'a, dyn Any + Send>>

Source

pub unsafe fn downcast_unchecked<T: Any>(self) -> Handle<'a, T>

Source§

impl<'a> Handle<'a, dyn Any + Send + Sync>

Source

pub fn downcast<T: Any>( self, ) -> Result<Handle<'a, T>, Handle<'a, dyn Any + Send + Sync>>

Source

pub unsafe fn downcast_unchecked<T: Any>(self) -> Handle<'a, T>

Source§

impl<'a, T> Handle<'a, [T]>

Source

pub const unsafe fn slice_from_raw_parts(data: *mut T, len: usize) -> Self

Source

pub fn new_slice_with_fn_in<A: Allocator, F: FnMut(usize) -> T>( arena: &'a Arena<A>, slice_len: usize, f: F, ) -> Self

Create a Handle slice of length slice_len, where each element is initialized by f.

The function f is called with the index of each item in the Handle.

§Examples
use rotunda::{Arena, handle::Handle};

let arena = Arena::new();

let handle = Handle::new_slice_with_fn_in(&arena, 5, |i| i * 2);

assert_eq!(handle.as_ref(), &[0, 2, 4, 6, 8]);
Source

pub fn new_slice_from_iter_in<A: Allocator, I: IntoIterator<Item = T>>( arena: &'a Arena<A>, iter: I, ) -> Self

Create a Handle slice containing the contents of the given iterator.

§Panics

If there is not enough room in the current Block to move all items from the iter into the Handle, this method will panic.

§Examples
use rotunda::{Arena, handle::Handle};

let arena = Arena::new();

let handle = Handle::new_slice_from_iter_in(
    &arena,
    [0, 1, 2, 3, 4]);

assert_eq!(handle.as_ref(), &[0, 1, 2, 3, 4]);
Source

pub const fn empty() -> Self

Create an empty Handle.

The returned handle is not backed by any memory.

§Examples
use rotunda::handle::Handle;

let handle = Handle::<[i32]>::empty();
assert_eq!(handle.as_ref(), &[]);
Source

pub const fn into_buffer(this: Self) -> Buffer<'a, T>

Create a Buffer from this Handle.

See Buffer::from_slice_handle for more details.

Source

pub fn split_off(this: &mut Self, at: usize) -> Handle<'a, [T]>

Source

pub const fn split_at( this: Self, mid: usize, ) -> (Handle<'a, [T]>, Handle<'a, [T]>)

Split the Handle at the given mid, returning the left and right sides of the array.

§Panics

This method will panic if mid is greater than or equal to self.len().

§Examples
use rotunda::{Arena, handle::Handle};

let arena = Arena::new();

let handle = Handle::new_slice_from_iter_in(&arena, [1, 2, 3, 4, 5, 6]);

let (lhs, rhs) = Handle::split_at(handle, 3);

assert_eq!(lhs.as_ref(), &[1, 2, 3]);
assert_eq!(rhs.as_ref(), &[4, 5, 6]);
Source

pub const fn split_at_checked( this: Self, mid: usize, ) -> Result<(Self, Self), Self>

Split the Handle at the given mid, returning the left and right sides of the array.

If mid is greater than or equal to self.len(), then the original Handle is returned in the Err variant.

§Examples
use rotunda::{Arena, handle::Handle};

let arena = Arena::new();

let handle = Handle::new_slice_from_iter_in(&arena, [1, 2, 3, 4, 5, 6]);

let Err(handle) = Handle::split_at_checked(handle, 7) else {
    unreachable!();
};

let (lhs, rhs) = Handle::split_at_checked(handle, 3).unwrap();

assert_eq!(lhs.as_ref(), &[1, 2, 3]);
assert_eq!(rhs.as_ref(), &[4, 5, 6]);
Source

pub const unsafe fn split_at_unchecked( this: Self, mid: usize, ) -> (Handle<'a, [T]>, Handle<'a, [T]>)

Split the Handle at the given mid, returning the left and right sides of the array.

§Safety

The given mid must be less than the length of the Buffer, otherwise this method will trigger undefined behavior.

§Examples
use rotunda::{Arena, handle::Handle};

let arena = Arena::new();

let handle = Handle::new_slice_from_iter_in(&arena, [1, 2, 3, 4, 5, 6, 7]);

let (lhs, rhs) = unsafe { Handle::split_at_unchecked(handle, 1) };

assert_eq!(lhs.as_ref(), &[1]);
assert_eq!(rhs.as_ref(), &[2, 3, 4, 5, 6, 7]);
Source

pub fn iter(&self) -> <&[T] as IntoIterator>::IntoIter

Source

pub fn iter_mut(&mut self) -> <&mut [T] as IntoIterator>::IntoIter

Source

pub fn iter_handles(this: Self) -> IntoIterHandles<'a, T>

Source

pub const fn transpose_into_uninit(this: Self) -> Handle<'a, [MaybeUninit<T>]>

Transpose a Handle of slice T into a slice of Uninit<T>.

§Examples
use rotunda::{Arena, handle::Handle};

let arena = Arena::new();

let handle = Handle::new_slice_from_iter_in(&arena, [1, 2, 3, 4, 5, 6, 7]);

let handle = Handle::transpose_into_uninit(handle);
Source§

impl<'a, T: Copy> Handle<'a, [T]>

Source

pub fn new_slice_splat_in<A: Allocator>( arena: &'a Arena<A>, slice_len: usize, value: T, ) -> Self

Create a new slice handle slice_len long, filled with value.

§Examples
use rotunda::{Arena, handle::Handle};

let arena = Arena::new();
let handle = Handle::new_slice_splat_in(&arena, 255, 123);

assert_eq!(handle.as_ref(), &[123; 255]);
Source§

impl<'a, T> Handle<'a, MaybeUninit<T>>

Source

pub const unsafe fn assume_init(this: Self) -> Handle<'a, T>

Consumes the Handle, returning a new Handle which treats its contents as fully initialized.

§Safety

This method must be called on a Handle which has had its contents fully initialized, otherwise it may permit access to uninitialized memory.

§Examples
use rotunda::{Arena, handle::Handle};

let arena = Arena::new();

let handle = unsafe {
    let mut handle = Handle::new_uninit_in(&arena);
    handle.as_mut().write(28);
    Handle::assume_init(handle)
};

assert_eq!(*handle, 28);
Source

pub const fn init(this: Self, value: T) -> Handle<'a, T>

Writes the value into the Handle and initilizes it.

Owership over value is transferred into the Handle. Any data previously written to the Handle is overwritten.

§Examples
use rotunda::{Arena, handle::Handle};

let arena = Arena::new();

let handle = Handle::new_uninit_in(&arena);
let handle = Handle::init(handle, 25);

assert_eq!(*handle, 25);
Source§

impl<'a, T> Handle<'a, [MaybeUninit<T>]>

Source

pub const unsafe fn assume_init_slice(this: Self) -> Handle<'a, [T]>

Source§

impl<'a> Handle<'a, str>

Source

pub fn new_str_in<S: ?Sized + AsRef<str>, A: Allocator>( arena: &'a Arena<A>, string: &S, ) -> Self

Create a new Handle containing the given string.

§Examples
use rotunda::{Arena, handle::Handle};

let arena = Arena::new();

let handle = Handle::new_str_in(&arena, "Some Data");

assert_eq!(&handle, "Some Data");
Source

pub const fn from_utf8( bytes: Handle<'a, [u8]>, ) -> Result<Self, FromUtf8Error<'a>>

Source

pub const unsafe fn from_utf8_unchecked(bytes: Handle<'a, [u8]>) -> Self

Source

pub const fn into_bytes(this: Self) -> Handle<'a, [u8]>

Source

pub const fn empty_str() -> Self

Create a Handle containing an empty str.

This method does not allocate.

§Examples
use rotunda::handle::Handle;

let handle = Handle::empty_str();
assert_eq!(&handle, "");

Trait Implementations§

Source§

impl<'a, T: ?Sized> AsMut<T> for Handle<'a, T>

Source§

fn as_mut(&mut self) -> &mut T

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<'a> AsRef<[u8]> for Handle<'a, str>

Source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<'a, T: ?Sized> AsRef<T> for Handle<'a, T>

Source§

fn as_ref(&self) -> &T

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<'a, T: ?Sized> Borrow<T> for Handle<'a, T>

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<'a, T: ?Sized> BorrowMut<T> for Handle<'a, T>

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<'a, R: ?Sized + BufRead> BufRead for Handle<'a, R>

Available on crate feature std only.
Source§

fn fill_buf(&mut self) -> Result<&[u8]>

Returns the contents of the internal buffer, filling it with more data, via Read methods, if empty. Read more
Source§

fn consume(&mut self, amount: usize)

Marks the given amount of additional bytes from the internal buffer as having been read. Subsequent calls to read only return bytes that have not been marked as read. Read more
Source§

fn has_data_left(&mut self) -> Result<bool, Error>

🔬This is a nightly-only experimental API. (buf_read_has_data_left)
Checks if there is any data left to be read. Read more
1.0.0 · Source§

fn read_until(&mut self, byte: u8, buf: &mut Vec<u8>) -> Result<usize, Error>

Reads all bytes into buf until the delimiter byte or EOF is reached. Read more
1.83.0 · Source§

fn skip_until(&mut self, byte: u8) -> Result<usize, Error>

Skips all bytes until the delimiter byte or EOF is reached. Read more
1.0.0 · Source§

fn read_line(&mut self, buf: &mut String) -> Result<usize, Error>

Reads all bytes until a newline (the 0xA byte) is reached, and append them to the provided String buffer. Read more
1.0.0 · Source§

fn split(self, byte: u8) -> Split<Self>
where Self: Sized,

Returns an iterator over the contents of this reader split on the byte byte. Read more
1.0.0 · Source§

fn lines(self) -> Lines<Self>
where Self: Sized,

Returns an iterator over the lines of this reader. Read more
Source§

impl<'a, T: ?Sized + Debug> Debug for Handle<'a, T>

Source§

fn fmt(&self, fmtr: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a, T> Default for Handle<'a, [T]>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'a> Default for Handle<'a, str>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'a, T: ?Sized> Deref for Handle<'a, T>

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<'a, T: ?Sized> DerefMut for Handle<'a, T>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl<'a, T: ?Sized + Display> Display for Handle<'a, T>

Source§

fn fmt(&self, fmtr: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a, T: ?Sized> Drop for Handle<'a, T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<'a, T> From<Buffer<'a, T>> for Handle<'a, [T]>

Source§

fn from(value: Buffer<'a, T>) -> Self

Converts to this type from the input type.
Source§

impl<'a, T> From<Handle<'a, [T]>> for Buffer<'a, T>

Source§

fn from(value: Handle<'a, [T]>) -> Self

Converts to this type from the input type.
Source§

impl<'a, T> From<Handle<'a, [T; 1]>> for Handle<'a, T>

Source§

fn from(value: Handle<'a, [T; 1]>) -> Self

Converts to this type from the input type.
Source§

impl<'a, T> From<Handle<'a, T>> for Handle<'a, [T]>

Source§

fn from(value: Handle<'a, T>) -> Self

Converts to this type from the input type.
Source§

impl<'a, T> From<Handle<'a, T>> for Handle<'a, [T; 1]>

Source§

fn from(value: Handle<'a, T>) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<Handle<'a, str>> for Handle<'a, [u8]>

Source§

fn from(value: Handle<'a, str>) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<Handle<'a, str>> for StringBuffer<'a>

Source§

fn from(value: Handle<'a, str>) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<StringBuffer<'a>> for Handle<'a, [u8]>

Source§

fn from(value: StringBuffer<'a>) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<StringBuffer<'a>> for Handle<'a, str>

Source§

fn from(value: StringBuffer<'a>) -> Self

Converts to this type from the input type.
Source§

impl<'a, T: ?Sized + Hash> Hash for Handle<'a, T>

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<'a, T, I: SliceIndex<[T]>> Index<I> for Handle<'a, [T]>

Source§

type Output = <[T] as Index<I>>::Output

The returned type after indexing.
Source§

fn index(&self, index: I) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<'a, T, I: SliceIndex<[T]>> IndexMut<I> for Handle<'a, [T]>

Source§

fn index_mut(&mut self, index: I) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<'sl: 'a, 'a, T: 'a> IntoIterator for &'sl Handle<'a, [T]>

Source§

type Item = &'a T

The type of the elements being iterated over.
Source§

type IntoIter = <&'a [T] as IntoIterator>::IntoIter

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'sl: 'a, 'a, T: 'a> IntoIterator for &'sl mut Handle<'a, [T]>

Source§

type Item = &'a mut T

The type of the elements being iterated over.
Source§

type IntoIter = <&'a mut [T] as IntoIterator>::IntoIter

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'a, T: Unpin> IntoIterator for Handle<'a, [T]>

Source§

type Item = T

The type of the elements being iterated over.
Source§

type IntoIter = <Buffer<'a, T> as IntoIterator>::IntoIter

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'a, T: ?Sized + Ord> Ord for Handle<'a, T>

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<'a, 'h, T: ?Sized + PartialEq> PartialEq<&'h Handle<'h, T>> for Handle<'a, T>

Source§

fn eq(&self, other: &&'h Handle<'h, T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, 'v, T: ?Sized + PartialEq> PartialEq<&'v T> for Handle<'a, T>

Source§

fn eq(&self, other: &&'v T) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, T: PartialEq> PartialEq<Handle<'_, [T]>> for Buffer<'a, T>

Source§

fn eq(&self, other: &Handle<'_, [T]>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> PartialEq<Handle<'_, str>> for StringBuffer<'a>

Source§

fn eq(&self, other: &Handle<'_, str>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, T: ?Sized + PartialEq> PartialEq<T> for Handle<'a, T>

Source§

fn eq(&self, other: &T) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, T: ?Sized + PartialEq> PartialEq for Handle<'a, T>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> PartialOrd<Handle<'_, str>> for StringBuffer<'a>

Source§

fn partial_cmp(&self, other: &Handle<'_, str>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<'a, T: ?Sized + PartialOrd> PartialOrd<T> for Handle<'a, T>

Source§

fn partial_cmp(&self, other: &T) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<'a, T: ?Sized + PartialOrd> PartialOrd for Handle<'a, T>

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<'a, T: ?Sized> Pointer for Handle<'a, T>

Source§

fn fmt(&self, fmtr: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a, R: ?Sized + Read> Read for Handle<'a, R>

Available on crate feature std only.
Source§

fn read(&mut self, buf: &mut [u8]) -> Result<usize>

Pull some bytes from this source into the specified buffer, returning how many bytes were read. Read more
Source§

fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize>

Like read, except that it reads into a slice of buffers. Read more
Source§

fn read_exact(&mut self, buf: &mut [u8]) -> Result<()>

Reads the exact number of bytes required to fill buf. Read more
Source§

fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize>

Reads all bytes until EOF in this source, placing them into buf. Read more
Source§

fn is_read_vectored(&self) -> bool

🔬This is a nightly-only experimental API. (can_vector)
Determines if this Reader has an efficient read_vectored implementation. Read more
1.0.0 · Source§

fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>

Reads all bytes until EOF in this source, appending them to buf. Read more
Source§

fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>

🔬This is a nightly-only experimental API. (read_buf)
Pull some bytes from this source into the specified buffer. Read more
Source§

fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>

🔬This is a nightly-only experimental API. (read_buf)
Reads the exact number of bytes required to fill cursor. Read more
1.0.0 · Source§

fn by_ref(&mut self) -> &mut Self
where Self: Sized,

Creates a “by reference” adapter for this instance of Read. Read more
1.0.0 · Source§

fn bytes(self) -> Bytes<Self>
where Self: Sized,

Transforms this Read instance to an Iterator over its bytes. Read more
1.0.0 · Source§

fn chain<R>(self, next: R) -> Chain<Self, R>
where R: Read, Self: Sized,

Creates an adapter which will chain this stream with another. Read more
1.0.0 · Source§

fn take(self, limit: u64) -> Take<Self>
where Self: Sized,

Creates an adapter which will read at most limit bytes from it. Read more
Source§

fn read_array<const N: usize>(&mut self) -> Result<[u8; N], Error>
where Self: Sized,

🔬This is a nightly-only experimental API. (read_array)
Read and return a fixed array of bytes from this source. Read more
Source§

impl<'a, T, const N: usize> TryFrom<Handle<'a, [T]>> for Handle<'a, [T; N]>

Source§

type Error = Handle<'a, [T]>

The type returned in the event of a conversion error.
Source§

fn try_from(value: Handle<'a, [T]>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'a> TryFrom<Handle<'a, [u8]>> for Handle<'a, str>

Source§

type Error = FromUtf8Error<'a>

The type returned in the event of a conversion error.
Source§

fn try_from(value: Handle<'a, [u8]>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'a> TryFrom<Handle<'a, [u8]>> for StringBuffer<'a>

Source§

type Error = FromUtf8Error<'a>

The type returned in the event of a conversion error.
Source§

fn try_from(value: Handle<'a, [u8]>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'a, T: ?Sized> TryFrom<RcHandle<'a, T>> for Handle<'a, T>

Source§

type Error = RcHandle<'a, T>

The type returned in the event of a conversion error.
Source§

fn try_from(value: RcHandle<'a, T>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'a, W: ?Sized + Write> Write for Handle<'a, W>

Available on crate feature std only.
Source§

fn write(&mut self, buf: &[u8]) -> Result<usize>

Writes a buffer into this writer, returning how many bytes were written. Read more
Source§

fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> Result<usize>

Like write, except that it writes from a slice of buffers. Read more
Source§

fn write_all(&mut self, buf: &[u8]) -> Result<()>

Attempts to write an entire buffer into this writer. Read more
Source§

fn flush(&mut self) -> Result<()>

Flushes this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
Source§

fn is_write_vectored(&self) -> bool

🔬This is a nightly-only experimental API. (can_vector)
Determines if this Writer has an efficient write_vectored implementation. Read more
Source§

fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>

🔬This is a nightly-only experimental API. (write_all_vectored)
Attempts to write multiple buffers into this writer. Read more
1.0.0 · Source§

fn write_fmt(&mut self, args: Arguments<'_>) -> Result<(), Error>

Writes a formatted string into this writer, returning any error encountered. Read more
1.0.0 · Source§

fn by_ref(&mut self) -> &mut Self
where Self: Sized,

Creates a “by reference” adapter for this instance of Write. Read more
Source§

impl<'a, T: ?Sized + Eq> Eq for Handle<'a, T>

Source§

impl<'a, T: ?Sized + Send> Send for Handle<'a, T>

Source§

impl<'a, T: ?Sized + Sync> Sync for Handle<'a, T>

Auto Trait Implementations§

§

impl<'a, T> Freeze for Handle<'a, T>
where T: ?Sized,

§

impl<'a, T> !RefUnwindSafe for Handle<'a, T>

§

impl<'a, T> Unpin for Handle<'a, T>
where T: Unpin + ?Sized,

§

impl<'a, T> !UnwindSafe for Handle<'a, T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.