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

Builder for creating textures.

This is used to control all the various configuration options and such to create a texture. More documentation is provided on each method itself.

Implementations§

source§

impl<'a> TextureBuilder<'a>

source

pub fn data(&mut self, buffer: &'a [u8]) -> &mut Self

Set the texture data of the texture.

See Render::create_texture for an example.

source

pub fn dimensions(&mut self, width: usize, height: usize) -> &mut Self

Set the width and height of the texture’s description.

For valid texture dimensions, width * height * TextureFormat::bytes_per_pixel should be equal to the texture’s buffer length.

See Render::create_texture for an example.

source

pub fn format(&mut self, format: TextureFormat) -> &mut Self

Set the format of the texture’s description.

For a valid texture format, TextureFormat::bytes_per_pixel * the texture dimensions’ width * height should be equal to the texture’s buffer length.

See Render::create_texture for an example.

source

pub fn name(&mut self, name: &'a str) -> &mut Self

Set the name of the texture.

Although optional, setting the name of a texture is highly recommended as it improves the debugging experience significantly.

The default is “unnamed”.

source

pub fn build(&self) -> Result<Texture, Error>

Build the texture.

See Render::create_texture for an example.

Errors

Returns an Error::InvalidArguments if the texture buffer’s length doesn’t match up against the texture’s dimensions and TextureFormat or if the texture dimensions have values lower or equal to 0.

Trait Implementations§

source§

impl<'a> Clone for TextureBuilder<'a>

source§

fn clone(&self) -> TextureBuilder<'a>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'a> Default for TextureBuilder<'a>

source§

fn default() -> TextureBuilder<'a>

Returns the “default value” for a type. Read more
source§

impl<'a> Copy for TextureBuilder<'a>

Auto Trait Implementations§

§

impl<'a> RefUnwindSafe for TextureBuilder<'a>

§

impl<'a> Send for TextureBuilder<'a>

§

impl<'a> Sync for TextureBuilder<'a>

§

impl<'a> Unpin for TextureBuilder<'a>

§

impl<'a> UnwindSafe for TextureBuilder<'a>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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 Twhere U: TryFrom<T>,

§

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.