Struct redox_buffer_pool::BufferSlice [−][src]
pub struct BufferSlice<'pool, I, H, E, G = NoGuard, C = BufferPool<I, H, E>> where
I: Integer,
H: Handle<I, E>,
E: Copy,
G: Marker,
C: AsBufferPool<I, H, E>, { /* fields omitted */ }
Expand description
A slice from the buffer pool, that can be read from or written to as a regular smart pointer.
The buffer slice struct has one lifetime argument, 'pool
, which is only used if the buffer
slice references the pool directly using a regular reference, which is the case for
acquire_borrowed_slice
. For slices allocated with acquire_strong_slice
and
acquire_weak_slice
, this lifetime will be 'static
.
Of the five generic type arguments, I
, H
, and E
, are more or less inherited from the
buffer pool; while only I
(for numbers) and E
(for the extra field) are used, they are
needed since the buffer pool itself also has to be involved for some operations. The G
parameter, is the guard type, which defaults to no guard at all, but allows the memory of the
buffer slice to stay protected and leak the memory if the guard couldn’t free it. The C
parameter is meant for wrappers structs over BufferPool
, to allow std::sync::Arc
s or
std::sync::Weak
s pointing to them instead.
The M
generic parameter is used for the “guarding mode”, an must implement the
[guard_trait::marker::Mode
] trait. It has no effect whatsoever on the data, but controls what
can and what cannot be done in safe code, with respect to the guard. The exclusive mode will
limit the ability to access the memory mutably or immutably, while the guard is present, while
the shared mode will only forbid mutable access, while the guard is active, but always allow
immutable access. Buffer slices can be converted to and from these types, though converting
from shared into exclusive requires proof that there is no aliasing going on.
Implementations
impl<'pool, I, H, E, G, C> BufferSlice<'pool, I, H, E, G, C> where
I: Integer,
H: Handle<I, E>,
E: Copy,
G: Marker,
C: AsBufferPool<I, H, E>,
impl<'pool, I, H, E, G, C> BufferSlice<'pool, I, H, E, G, C> where
I: Integer,
H: Handle<I, E>,
E: Copy,
G: Marker,
C: AsBufferPool<I, H, E>,
Checks whether the pool that owns this slice is still alive, or if it has dropped. Note that this only makes sense for weak buffer slices, since buffer slices tied to a lifetime cannot outlive their pools (checked for at compile time), while strong buffer slices ensure at runtime that they outlive their pools.
For weak buffer slices, this method should be called before doing anything with the slice, since a single deref could make it panic if the buffer isn’t there anymore.
Constructs an immutable slice from this buffer, provided that there is no guard protecting the memory.
Construct a mutable slice from this buffer.
Get the capacity of the allocation slice. This is almost always the same as the length, but may be larger in case the allocator chose a larger size to align the range afterwards.
Get the offset of the underlying possibly non-continuously-organized mmap, that was added
as part of BufferPool::begin_expand
.
Trait Implementations
impl<'pool, I, H, E, G, C> Deref for BufferSlice<'pool, I, H, E, G, C> where
I: Integer,
H: Handle<I, E>,
E: Copy,
G: Marker,
C: AsBufferPool<I, H, E>,
impl<'pool, I, H, E, G, C> Deref for BufferSlice<'pool, I, H, E, G, C> where
I: Integer,
H: Handle<I, E>,
E: Copy,
G: Marker,
C: AsBufferPool<I, H, E>,
impl<'pool, I, H, E, G, C> DerefMut for BufferSlice<'pool, I, H, E, G, C> where
I: Integer,
H: Handle<I, E>,
E: Copy,
G: Marker,
C: AsBufferPool<I, H, E>,
impl<'pool, I, H, E, G, C> DerefMut for BufferSlice<'pool, I, H, E, G, C> where
I: Integer,
H: Handle<I, E>,
E: Copy,
G: Marker,
C: AsBufferPool<I, H, E>,
impl<'pool, I, H, E, G, C> Drop for BufferSlice<'pool, I, H, E, G, C> where
I: Integer,
E: Copy,
H: Handle<I, E>,
G: Marker,
C: AsBufferPool<I, H, E>,
impl<'pool, I, H, E, G, C> Drop for BufferSlice<'pool, I, H, E, G, C> where
I: Integer,
E: Copy,
H: Handle<I, E>,
G: Marker,
C: AsBufferPool<I, H, E>,
impl<'pool, I, H, E, C> Guarded for BufferSlice<'pool, I, H, E, Guard, C> where
I: Integer,
H: Handle<I, E>,
E: Copy,
C: AsBufferPool<I, H, E>,
impl<'pool, I, H, E, C> Guarded for BufferSlice<'pool, I, H, E, Guard, C> where
I: Integer,
H: Handle<I, E>,
E: Copy,
C: AsBufferPool<I, H, E>,
The target pointee that this pointer may dereference into. There are no real restrictions
to what this type can be. However, the user must not assume that simply because a &Target
reference is protected, that references indirectly derived (via Deref
and other traits)
would also be protected. Read more
Borrow the pointee, into a fixed reference that can be sent directly and safely to e.g. memory-sharing completion-based I/O interfaces. Read more
impl<'pool, I, H, E, C> GuardedMut for BufferSlice<'pool, I, H, E, Guard, C> where
I: Integer,
H: Handle<I, E>,
E: Copy,
C: AsBufferPool<I, H, E>,
impl<'pool, I, H, E, C> GuardedMut for BufferSlice<'pool, I, H, E, Guard, C> where
I: Integer,
H: Handle<I, E>,
E: Copy,
C: AsBufferPool<I, H, E>,
Borrow the pointee mutably, into a fixed reference that can be sent directly and safely to e.g. memory-sharing completion-based I/O interfaces. Read more
impl<'pool, I, H, E, G, C> Send for BufferSlice<'pool, I, H, E, G, C> where
I: Integer,
H: Handle<I, E> + Send + Sync,
E: Copy + Send,
G: Marker,
C: AsBufferPool<I, H, E>,
Auto Trait Implementations
impl<'pool, I, H, E, G = NoGuard, C = BufferPool<I, H, E>> !RefUnwindSafe for BufferSlice<'pool, I, H, E, G, C>
impl<'pool, I, H, E, G, C> Unpin for BufferSlice<'pool, I, H, E, G, C> where
E: Unpin,
G: Unpin,
I: Unpin,
impl<'pool, I, H, E, G = NoGuard, C = BufferPool<I, H, E>> !UnwindSafe for BufferSlice<'pool, I, H, E, G, C>