Context

Struct Context 

Source
pub struct Context { /* private fields */ }
Expand description

The core context. All configuration should be done through this.

Implementations§

Source§

impl Context

Source

pub fn with_threads(threads: usize, config: Config) -> Result<Self, Error>

Create a new context from the given config (see ConfigBuilder for more information on this config), and sets the number of threads that the internal encoder/decoder will use. See Context::new, which does the same thing but automatically guesses the correct thread count by trying to use 8 threads but falling back to the number of cores if it is less than 8. Returns an error in the case that the config is invalid or the context could not be allocated.

Source

pub fn new(config: Config) -> Result<Self, Error>

Create a new context from the given config (see ConfigBuilder for more information on this config). Returns an error in the case that the config is invalid or the context could not be allocated.

Source

pub fn compress<D, T, L>( &mut self, image: &Image<T>, swizzle: Swizzle, ) -> Result<Vec<u8>, Error>
where D: DataType, T: Deref<Target = [L]>, L: Deref<Target = [D]>,

Compress the given image, returning a byte vector that can be sent to the GPU.

Source

pub fn decompress_into<D, T, L>( &mut self, data: &[u8], out: &mut Image<T>, swizzle: Swizzle, ) -> Result<(), Error>
where D: DataType, T: DerefMut<Target = [L]>, L: DerefMut<Target = [D]>,

Decompress an image into a pre-existing buffer. The metadata (size and border padding) must already be set and enough space must be reserved in out.data for the output pixels (RGBA).

Source

pub fn decompress<D>( &mut self, data: &[u8], extents: Extents, swizzle: Swizzle, ) -> Result<Image<Vec<Vec<D>>>, Error>
where D: DataType,

Decompress an image. The metadata is not stored in the compressed data itself, and should be stored as a separate header.

Trait Implementations§

Source§

impl Default for Context

Source§

fn default() -> Self

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

impl Drop for Context

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for Context

Source§

impl Sync for Context

Auto Trait Implementations§

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.