pub struct SpaceTransaction { /* private fields */ }Expand description
A Transaction that modifies a Space.
Implementations§
Source§impl SpaceTransaction
impl SpaceTransaction
Sourcepub fn at(&mut self, cube: Cube) -> &mut CubeTransaction
pub fn at(&mut self, cube: Cube) -> &mut CubeTransaction
Allows modifying the part of this transaction which is a CubeTransaction at the given
cube, creating it if necessary (as CubeTransaction::default()).
You can replace the transaction or use CubeTransaction::merge_from() to merge in
another transaction.
This is for incremental construction of a complex transaction;
to create a transaction affecting a single cube, CubeTransaction::at() will be more
convenient.
Sourcepub fn filling<F>(region: GridAab, function: F) -> Self
pub fn filling<F>(region: GridAab, function: F) -> Self
Construct a SpaceTransaction which modifies a volume by applying a CubeTransaction
computed by function to each cube.
Sourcepub fn set_cube(
cube: impl Into<Cube>,
old: Option<Block>,
new: Option<Block>,
) -> Self
pub fn set_cube( cube: impl Into<Cube>, old: Option<Block>, new: Option<Block>, ) -> Self
Construct a SpaceTransaction for a single cube.
If old is not None, requires that the existing block is that block or the
transaction will fail.
If new is not None, replaces the existing block with new.
TODO: Consider replacing all uses of this with CubeTransaction::replacing().
Sourcepub fn draw_target<C>(
&mut self,
transform: Gridgid,
) -> DrawingPlane<'_, Self, C>
pub fn draw_target<C>( &mut self, transform: Gridgid, ) -> DrawingPlane<'_, Self, C>
Provides an DrawTarget
adapter for 2.5D drawing.
For more information on how to use this, see
all_is_cubes::drawing.
Sourcepub fn nonconserved(self) -> Self
pub fn nonconserved(self) -> Self
Marks all cube modifications in this transaction as non-conservative.
This means that two transactions which both place the same block in a given cube may be merged, whereas the default state is that they will conflict (on the principle that such a merge could cause there to be fewer total occurrences of that block than intended).
Also, the transaction will not fail if some of its cubes are outside the bounds of
the Space.
Sourcepub fn behaviors(t: BehaviorSetTransaction<Space>) -> Self
pub fn behaviors(t: BehaviorSetTransaction<Space>) -> Self
Modify the space’s BehaviorSet.
Sourcepub fn add_behavior<B>(bounds: GridAab, behavior: B) -> Self
pub fn add_behavior<B>(bounds: GridAab, behavior: B) -> Self
Add a behavior to the Space.
This is a shortcut for creating a BehaviorSetTransaction.
Sourcepub fn bounds_only_cubes(&self) -> Option<GridAab>
pub fn bounds_only_cubes(&self) -> Option<GridAab>
Computes the region of cubes directly affected by this transaction. Ignores behaviors.
Returns None if no cubes are affected.
TODO: Handle the case where the total volume is too large.
(Maybe GridAab should lose that restriction.)
Sourcepub fn bounds(&self) -> Option<GridAab>
pub fn bounds(&self) -> Option<GridAab>
Computes the region affected by this transaction.
Returns None if no specific regions of the space are affected.
Sourcepub fn execute_m(
self,
target: &mut Mutation<'_, '_>,
) -> Result<(), ExecuteError<Self>>
pub fn execute_m( self, target: &mut Mutation<'_, '_>, ) -> Result<(), ExecuteError<Self>>
As Transaction::execute(), but taking a Mutation instead of a Space.
Trait Implementations§
Source§impl Clone for SpaceTransaction
impl Clone for SpaceTransaction
Source§fn clone(&self) -> SpaceTransaction
fn clone(&self) -> SpaceTransaction
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SpaceTransaction
impl Debug for SpaceTransaction
Source§impl Default for SpaceTransaction
impl Default for SpaceTransaction
Source§fn default() -> SpaceTransaction
fn default() -> SpaceTransaction
Source§impl<'a> From<&'a VoxelBrush<'a>> for SpaceTransaction
impl<'a> From<&'a VoxelBrush<'a>> for SpaceTransaction
Source§fn from(brush: &'a VoxelBrush<'a>) -> Self
fn from(brush: &'a VoxelBrush<'a>) -> Self
Converts the brush into an equivalent transaction, as by
VoxelBrush::paint_transaction at the origin.
Source§impl<'a> From<VoxelBrush<'a>> for SpaceTransaction
impl<'a> From<VoxelBrush<'a>> for SpaceTransaction
Source§fn from(brush: VoxelBrush<'a>) -> Self
fn from(brush: VoxelBrush<'a>) -> Self
Converts the brush into an equivalent transaction, as by
VoxelBrush::paint_transaction at the origin.
Source§impl Merge for SpaceTransaction
impl Merge for SpaceTransaction
Source§type MergeCheck = <BehaviorSetTransaction<Space> as Merge>::MergeCheck
type MergeCheck = <BehaviorSetTransaction<Space> as Merge>::MergeCheck
Merge::check_merge to Merge::commit_merge.
This may be used to pass precalculated values to speed up the merge phase,
but also makes it difficult to accidentally merge without checking.Source§type Conflict = SpaceTransactionConflict
type Conflict = SpaceTransactionConflict
Source§fn check_merge(&self, other: &Self) -> Result<Self::MergeCheck, Self::Conflict>
fn check_merge(&self, other: &Self) -> Result<Self::MergeCheck, Self::Conflict>
Ok containing data which may be passed to Self::commit_merge(). Read moreSource§fn commit_merge(&mut self, other: Self, check: Self::MergeCheck)
fn commit_merge(&mut self, other: Self, check: Self::MergeCheck)
other into self so that it has both effects simultaneously.
This operation must be commutative and have Default::default() as the identity. Read moreSource§impl PartialEq for SpaceTransaction
impl PartialEq for SpaceTransaction
Source§impl Transaction for SpaceTransaction
impl Transaction for SpaceTransaction
Source§type Context<'a> = ReadTicket<'a>
type Context<'a> = ReadTicket<'a>
() if none is needed.Source§type CommitCheck = CommitCheck
type CommitCheck = CommitCheck
Transaction::check to Transaction::commit.
This may be used to pass precalculated values to speed up the commit phase,
or even lock guards or similar, but also makes it slightly harder to accidentally
call commit without check.Source§type Output = Infallible
type Output = Infallible
Transaction::commit() or Transaction::execute().
Each commit may produce any number of these messages. Read moreSource§type Mismatch = SpaceTransactionMismatch
type Mismatch = SpaceTransactionMismatch
Self::check(). Read moreSource§fn check(
&self,
space: &Space,
read_ticket: Self::Context<'_>,
) -> Result<Self::CommitCheck, Self::Mismatch>
fn check( &self, space: &Space, read_ticket: Self::Context<'_>, ) -> Result<Self::CommitCheck, Self::Mismatch>
Source§fn commit(
self,
space: &mut Space,
check: Self::CommitCheck,
_outputs: &mut dyn FnMut(Self::Output),
) -> Result<(), CommitError>
fn commit( self, space: &mut Space, check: Self::CommitCheck, _outputs: &mut dyn FnMut(Self::Output), ) -> Result<(), CommitError>
check value should have
been created by a prior call to Transaction::check(). Read moreSource§impl VisitHandles for SpaceTransaction
impl VisitHandles for SpaceTransaction
Source§fn visit_handles(&self, visitor: &mut dyn HandleVisitor)
fn visit_handles(&self, visitor: &mut dyn HandleVisitor)
impl Eq for SpaceTransaction
impl StructuralPartialEq for SpaceTransaction
Auto Trait Implementations§
impl Freeze for SpaceTransaction
impl !RefUnwindSafe for SpaceTransaction
impl Send for SpaceTransaction
impl Sync for SpaceTransaction
impl Unpin for SpaceTransaction
impl !UnwindSafe for SpaceTransaction
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
Source§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates Self using default().
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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