[][src]Struct vulkano::buffer::BufferSlice

pub struct BufferSlice<T: ?Sized, B> { /* fields omitted */ }

A subpart of a buffer.

This object doesn't correspond to any Vulkan object. It exists for API convenience.

Example

Creating a slice:

This example is not tested
use vulkano::buffer::BufferSlice;
let _slice = BufferSlice::from(&buffer);

Selecting a slice of a buffer that contains [T]:

This example is not tested
use vulkano::buffer::BufferSlice;
let _slice = BufferSlice::from(&buffer).slice(12 .. 14).unwrap();

Methods

impl<T: ?Sized, B> BufferSlice<T, B>[src]

pub fn from_typed_buffer_access(r: B) -> BufferSlice<T, B> where
    B: TypedBufferAccess<Content = T>, 
[src]

pub fn buffer(&self) -> &B[src]

Returns the buffer that this slice belongs to.

pub fn offset(&self) -> usize[src]

Returns the offset of that slice within the buffer.

pub fn size(&self) -> usize[src]

Returns the size of that slice in bytes.

pub unsafe fn slice_custom<F, R: ?Sized>(self, f: F) -> BufferSlice<R, B> where
    F: for<'r> FnOnce(&'r T) -> &'r R, 
[src]

Builds a slice that contains an element from inside the buffer.

This method builds an object that represents a slice of the buffer. No actual operation is performed.

Example

TODO

Safety

The object whose reference is passed to the closure is uninitialized. Therefore you must not access the content of the object.

You must return a reference to an element from the parameter. The closure must not panic.

pub unsafe fn reinterpret<R: ?Sized>(self) -> BufferSlice<R, B>[src]

Changes the T generic parameter of the BufferSlice to the desired type. This can be useful when you have a buffer with various types of data and want to create a typed slice of a region that contains a single type of data.

Example

let blob_slice: BufferSlice<[u8], Arc<ImmutableBuffer<[u8]>>> = return;
let vertex_slice: BufferSlice<[VertexImpl], Arc<ImmutableBuffer<[u8]>>> = unsafe {
    blob_slice.reinterpret::<[VertexImpl]>()
};

Safety

Correct offset and size must be ensured before using this BufferSlice on the device. See BufferSlice::slice for adjusting these properties.

impl<T, B> BufferSlice<[T], B>[src]

pub fn len(&self) -> usize[src]

Returns the number of elements in this slice.

pub fn index(self, index: usize) -> Option<BufferSlice<T, B>>[src]

Reduces the slice to just one element of the array.

Returns None if out of range.

pub fn slice(self, range: Range<usize>) -> Option<BufferSlice<[T], B>>[src]

Reduces the slice to just a range of the array.

Returns None if out of range.

Trait Implementations

impl<T: ?Sized, B> BufferAccess for BufferSlice<T, B> where
    B: BufferAccess
[src]

impl<T: ?Sized, B> TypedBufferAccess for BufferSlice<T, B> where
    B: BufferAccess
[src]

type Content = T

The type of the content.

impl<T: ?Sized, B> DeviceOwned for BufferSlice<T, B> where
    B: DeviceOwned
[src]

impl<T, B> From<BufferSlice<T, B>> for BufferSlice<[T], B>[src]

impl<T: ?Sized, B> Clone for BufferSlice<T, B> where
    B: Clone
[src]

Auto Trait Implementations

impl<T: ?Sized, B> Send for BufferSlice<T, B> where
    B: Send,
    T: Send

impl<T: ?Sized, B> Sync for BufferSlice<T, B> where
    B: Sync,
    T: Sync

impl<T: ?Sized, B> Unpin for BufferSlice<T, B> where
    B: Unpin,
    T: Unpin

impl<T: ?Sized, B> UnwindSafe for BufferSlice<T, B> where
    B: UnwindSafe,
    T: UnwindSafe

impl<T: ?Sized, B> RefUnwindSafe for BufferSlice<T, B> where
    B: RefUnwindSafe,
    T: RefUnwindSafe

Blanket Implementations

impl<T> DeviceOwned for T where
    T: Deref,
    <T as Deref>::Target: DeviceOwned
[src]

impl<T> Content for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]