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

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

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

Creates a stream from raw bytes.

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

Returns length of the stream in value groups.

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

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

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.