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::Arcs or std::sync::Weaks 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

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 offset of the buffer pool where this was allocated.

Get the length of the allocation slice.

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.

Check whether the slice is empty or not.

Get the offset of the underlying possibly non-continuously-organized mmap, that was added as part of BufferPool::begin_expand.

Get the size of the mmap region this slice was allocated in.

Get the extra field from the mmap region this slice belongs to, copied.

Trait Implementations

Performs the conversion.

Performs the conversion.

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Formats the value using the given formatter. Read more

The resulting type after dereferencing.

Dereferences the value.

Mutably dereferences the value.

Executes the destructor for this type. Read more

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

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

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Apply a function to the pointee, creating a new guarded type that dereferences into the result of that function. Read more

Apply a fallible function to the pointee, creating a new guarded type that dereferences into the result of that function. Read more

Apply a function to the pointee, creating a new guarded type that dereferences into the result of that function. Read more

Apply a fallible function to the pointee, creating a new guarded type that dereferences into the result of that function. Read more

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.