Read

Struct Read 

Source
pub struct Read<'ticket> { /* private fields */ }
Expand description

Read access to a Space that may be currently in a Universe.

Obtain this using Handle::read() or Space::read().

Implementations§

Source§

impl Read<'_>

Source

pub fn bounds(&self) -> GridAab

Returns the GridAab describing the bounds of this space; no blocks may exist outside it.

Source

pub fn get_block_index(&self, position: impl Into<Cube>) -> Option<BlockIndex>

Returns the internal unstable numeric ID for the block at the given position, which may be mapped to a Block by Read::block_data(). If you are looking for simple access, use space[position] (the core::ops::Index trait) instead.

These IDs may be used to perform efficient processing of many blocks, but they may be renumbered after any mutation.

Source

pub fn get_evaluated(&self, position: impl Into<Cube>) -> &EvaluatedBlock

Returns the EvaluatedBlock of the block in this space at the given position.

If out of bounds, returns the evaluation of AIR.

Source

pub fn get_lighting(&self, cube: impl Into<Cube>) -> PackedLight

Returns the light occupying the given cube.

This value may be considered as representing the average of the light reflecting off of all surfaces within, or immediately adjacent to and facing toward, this cube. If there are no such surfaces, or if the given position is out of bounds, the result is arbitrary. If the position is within an opaque block, the result is black.

Lighting is updated asynchronously after modifications, so all above claims about the meaning of this value are actually “will eventually be, if no more changes are made”.

Source

pub fn extract<'s, C, V>( &'s self, bounds: GridAab, extractor: impl FnMut(Extract<'s>) -> V, ) -> Vol<C>
where C: Deref<Target = [V]> + FromIterator<V>,

Copy data out of a portion of the space in a caller-chosen format.

The given bounds must be fully contained within self.bounds().

Source

pub fn block_data(&self) -> &[SpaceBlockData]

Returns data about all the blocks assigned internal IDs (indices) in the space, as well as placeholder data for any deallocated indices.

The indices of this slice correspond to the results of Space::get_block_index().

Source

pub fn fluff( &self, ) -> impl Listen<Msg = SpaceFluff, Listener = DynListener<SpaceFluff>> + '_

Returns the source of fluff occurring in this space.

Source

pub fn physics(&self) -> &SpacePhysics

Returns the current SpacePhysics data, which determines global characteristics such as the behavior of light and gravity.

Source

pub fn spawn(&self) -> &Spawn

Returns the current default Spawn, which determines where new Characters are placed in the space if no alternative applies.

Source

pub fn behaviors(&self) -> &BehaviorSet<Space>

Returns the BehaviorSet of behaviors attached to this space.

Trait Implementations§

Source§

impl<'ticket> Clone for Read<'ticket>

Source§

fn clone(&self) -> Read<'ticket>

Returns a duplicate 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 Debug for Read<'_>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<T: Into<Cube>> Index<T> for Read<'_>

Source§

fn index(&self, position: T) -> &Self::Output

Gets a reference to the block in this space at the given position.

If the position is out of bounds, returns AIR.

There is no corresponding IndexMut implementation; use Mutation::set() or Mutation::fill() to modify blocks.

Source§

type Output = Block

The returned type after indexing.
Source§

impl Listen for Read<'_>

Registers a listener for mutations of this space.

Source§

type Msg = SpaceChange

The type of message which may be obtained from this source. Read more
Source§

type Listener = <Notifier<<Read<'_> as Listen>::Msg, Arc<dyn Listener<<Read<'_> as Listen>::Msg> + Sync + Send>> as Listen>::Listener

The type which all added listeners must be convertible to.
Source§

fn listen_raw(&self, listener: Self::Listener)

Subscribe the given Listener to this source of messages. Read more
Source§

fn listen<L>(&self, listener: L)
where L: IntoListener<Self::Listener, Self::Msg>, Self: Sized,

Subscribe the given Listener to this source of messages. Read more
Source§

impl Serialize for Read<'_>

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<'ticket> Copy for Read<'ticket>

Auto Trait Implementations§

§

impl<'ticket> Freeze for Read<'ticket>

§

impl<'ticket> !RefUnwindSafe for Read<'ticket>

§

impl<'ticket> Send for Read<'ticket>

§

impl<'ticket> Sync for Read<'ticket>

§

impl<'ticket> Unpin for Read<'ticket>

§

impl<'ticket> !UnwindSafe for Read<'ticket>

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> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
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<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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 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.
Source§

impl<T> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> ConditionalSend for T
where T: Send,