[][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.


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();


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

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

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, 

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.




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.


let blob_slice: BufferSlice<[u8], Arc<ImmutableBuffer<[u8]>>> = return;
let vertex_slice: BufferSlice<[VertexImpl], Arc<ImmutableBuffer<[u8]>>> = unsafe {


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

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

type Content = T

The type of the content.

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

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

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

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

impl<T> Content for T[src]

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

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

impl<T> ToOwned for T where
    T: Clone

type Owned = T

The resulting type after obtaining ownership.

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

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

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