Enum tiled::TileLayer

source ·
pub enum TileLayer<'map> {
    Finite(FiniteTileLayer<'map>),
    Infinite(InfiniteTileLayer<'map>),
}
Expand description

A map layer containing tiles in some way. May be finite or infinite.

Variants§

§

Finite(FiniteTileLayer<'map>)

An finite tile layer; Also see FiniteTileLayer.

§

Infinite(InfiniteTileLayer<'map>)

An infinite tile layer; Also see InfiniteTileLayer.

Implementations§

source§

impl<'map> TileLayer<'map>

source

pub fn get_tile(&self, x: i32, y: i32) -> Option<LayerTile<'map>>

Obtains the tile present at the position given.

If the position given is invalid or the position is empty, this function will return None.

source

pub fn width(&self) -> Option<u32>

The width of this layer, if finite, or None if infinite.

§Example
use tiled::LayerType;
use tiled::Loader;

let width = match layer {
    tiled::TileLayer::Finite(finite) => Some(finite.width()),
    _ => None,
};

// These are both equal, and they achieve the same thing; However, matching on the layer
// type is significantly more verbose. If you already know the layer type, then it is
// slighly faster to use its respective width method.
assert_eq!(width, layer.width());
source

pub fn height(&self) -> Option<u32>

The height of this layer, if finite, or None if infinite.

§Example
use tiled::LayerType;
use tiled::Loader;

let height = match layer {
    tiled::TileLayer::Finite(finite) => Some(finite.height()),
    _ => None,
};

// These are both equal, and they achieve the same thing; However, matching on the layer
// type is significantly more verbose. If you already know the layer type, then it is
// slighly faster to use its respective height method.
assert_eq!(height, layer.height());

Trait Implementations§

source§

impl<'map> Debug for TileLayer<'map>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'map> Freeze for TileLayer<'map>

§

impl<'map> RefUnwindSafe for TileLayer<'map>

§

impl<'map> Send for TileLayer<'map>

§

impl<'map> Sync for TileLayer<'map>

§

impl<'map> Unpin for TileLayer<'map>

§

impl<'map> UnwindSafe for TileLayer<'map>

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

§

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

§

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.