Struct Stream

Source
pub struct Stream<'a> { /* private fields */ }
Expand description

A stream of value groups which are meant to be used together (e.g. 3 floats representing a vertex position).

Implementations§

Source§

impl<'a> Stream<'a>

Source

pub fn from_slice<T>(slice: &'a [T]) -> Self

Creates a stream from a slice.

§Example
use meshopt_rs::Stream;

let positions = vec![[1.0, 2.0, 3.0], [2.0, 3.0, 4.0], [5.0, 6.0, 7.0]];
let stream = Stream::from_slice(&positions);

assert_eq!(stream.len(), positions.len());
Source

pub fn from_slice_with_subset<T>(slice: &'a [T], subset: Range<usize>) -> Self

Creates a stream from a slice with the given byte subset.

§Arguments
  • subset: subset of data to use inside a T
§Example
use meshopt_rs::Stream;

#[derive(Clone, Default)]
#[repr(C)]
struct Vertex {
    position: [f32; 3],
    normal: [f32; 3],
    uv: [f32; 2],
}

let normals_offset = std::mem::size_of::<f32>() * 3;
let normals_size = std::mem::size_of::<f32>() * 3;

let vertices = vec![Vertex::default(); 1];
let normal_stream = Stream::from_slice_with_subset(&vertices, normals_offset..normals_offset+normals_size);

assert_eq!(normal_stream.len(), 1);
Source

pub fn from_bytes<T>( slice: &'a [T], stride: usize, subset: Range<usize>, ) -> Self

Creates a stream from raw bytes.

§Arguments
  • stride: stride between value groups
  • subset: subset of data to use inside a value group
Source

pub fn len(&self) -> usize

Returns length of the stream in value groups.

Auto Trait Implementations§

§

impl<'a> Freeze for Stream<'a>

§

impl<'a> RefUnwindSafe for Stream<'a>

§

impl<'a> Send for Stream<'a>

§

impl<'a> Sync for Stream<'a>

§

impl<'a> Unpin for Stream<'a>

§

impl<'a> UnwindSafe for Stream<'a>

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