[][src]Struct crunch::Packer

pub struct Packer<T> { /* fields omitted */ }

A packer for items of type Item<T>.

Implementations

impl<T> Packer<T>[src]

pub fn new() -> Self[src]

Create a new, empty packer.

pub fn with_capacity(capacity: usize) -> Self[src]

Create a packer with an initial capacity to prevent collection resizing.

pub fn with_items<I: IntoIterator<Item = Item<T>>>(items: I) -> Self[src]

Create a packer initialized with the collection of items.

impl<T: Clone> Packer<T>[src]

pub fn clear(&mut self) -> &mut Self[src]

pub fn push(&mut self, item: Item<T>) -> &mut Self[src]

pub fn extend<I: IntoIterator<Item = Item<T>>>(&mut self, items: I) -> &mut Self[src]

pub fn pack(
    &mut self,
    into_rect: Rect
) -> Result<PackedItems<T>, PackedItems<T>>
[src]

Attempt to pack all the items into into_rect. The returned PackedItems will contain positions for all packed items on success, or just the items the packer was able to successfull pack before failing.

This function uses some internal intermediary collections, which is why it is mutable, so it cannot be called but it is valid to call it multiple times with different into_rect values.

If you want to attempt to pack the same item list into several different into_rect, it is valid to call this function multiple times on the same Packer, and it will re-use its intermediary data structures.

pub fn pack_into_po2(
    &mut self,
    max_size: usize
) -> Result<(usize, usize, PackedItems<T>), ()>
[src]

Attempts to pack the supplied items into the smallest power of 2 container it possibly can while not exceeding the provided max_size.

On success, returns the size of the container (a power of 2) and the packed items.

Trait Implementations

impl<T> Default for Packer<T>[src]

fn default() -> Self[src]

Default packer, equivalent to Packer::new().

Auto Trait Implementations

impl<T> RefUnwindSafe for Packer<T> where
    T: RefUnwindSafe

impl<T> Send for Packer<T> where
    T: Send

impl<T> Sync for Packer<T> where
    T: Sync

impl<T> Unpin for Packer<T> where
    T: Unpin

impl<T> UnwindSafe for Packer<T> where
    T: UnwindSafe

Blanket Implementations

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

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

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

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.