[][src]Enum semeion::entity::lifespan::Lifespan

pub enum Lifespan {
    Ephemeral(Span),
    Immortal,
}

The lifespan of an entity.

Variants

Ephemeral(Span)

The Entity ages as the time goes on, and its lifespan decreases generation after generation.

Immortal

The Entity is not affected by the passing of time, and its lifespan does not decrease, but it can still be killed by other entities since its lifespan is defined and can be altered.

Implementations

impl Lifespan[src]

pub fn with_span(span: impl Into<Span>) -> Self[src]

Constructs an Ephemeral Lifespan with the given span value.

pub fn is_alive(&self) -> bool[src]

Returns true only if there is lifespan left. It will always return true if immortal.

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

Shorten the lifespan by a single unit of span, it has no effect if immortal. Returns the Lifespan left.

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

Lengthen the lifespan by a single unit of span, it has no effect if immortal. Returns the Lifespan left.

pub fn shorten_by(&mut self, amount: impl Into<Span>) -> &Self[src]

Shorten the lifespan by the given amount of span, it has no effect if immortal. Returns the Lifespan left.

pub fn lengthen_by(&mut self, amount: impl Into<Span>) -> &Self[src]

Lengthen the lifespan by the given amount of span, it has no effect if immortal. Returns the Lifespan left.

pub fn clear(&mut self)[src]

Replaces the lifespan with a new empty one, by effectively representing the death of the entity. This method will have an effect also on an immortal lifespan.

pub fn span(self) -> Option<Span>[src]

Gets the Span of the Lifespan if self is Ephemeral, otherwise returns None.

pub fn length(self) -> Option<u64>[src]

Gets the length of the Lifespan if self is Ephemeral, otherwise returns None.

Trait Implementations

impl Clone for Lifespan[src]

impl Copy for Lifespan[src]

impl Debug for Lifespan[src]

impl Eq for Lifespan[src]

impl Hash for Lifespan[src]

impl Ord for Lifespan[src]

impl PartialEq<Lifespan> for Lifespan[src]

impl PartialOrd<Lifespan> for Lifespan[src]

impl StructuralEq for Lifespan[src]

impl StructuralPartialEq for Lifespan[src]

Auto Trait Implementations

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> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.