pub struct Handle<T> { /* private fields */ }Expand description
§A handle that references a stored object
You can get an instance of Handle by inserting an object into a store. A
handle dereferences to the object it points to, via its Deref
implementation.
§Bare objects and stored objects
A bare object is just that: an instance of a bare object type. Once a bare
objects is inserted into storage, it becomes a stored object. A stored
object is owned by the store, and can be referenced through instances of
Handle.
The point of doing this, is to provide objects with a unique identity, via their location within storage. The importance of this is expanded upon in the next section.
§Equality and Identity
Most objects have Eq/PartialEq implementations that can be used to
determine equality. Those implementations are derived, meaning two objects
are equal, if all of their fields are equal. This can be used to compare
objects structurally. Handle’s own Eq/PartialEq implementations
defer to those of the stored object it references.
However, that two objects are equal does not mean they are identical.
This distinction is relevant, because non-identical objects that are supposed to be equal can in fact end up equal, if they are created based on simple input data (as you might have in a unit test). But they might end up slightly different, if they are created based on complex input data (as you might have in a real-world scenario). This situation would most likely result in a bug that is not easily caught in testing.
You can compare the identity of two Handles, by comparing the values
returned by Handle::id.
§Validation Must Use Identity
To prevent situations where everything looks fine during development, but you end up with a bug in production, any validation code that compares objects and expects them to be the same, must do that comparison based on identity, not equality. That way, this problem can never happen, because we never expect non-identical objects to be equal.
Implementations§
Trait Implementations§
Source§impl BoundingVolume<2> for Handle<HalfEdge>
impl BoundingVolume<2> for Handle<HalfEdge>
Source§impl<T> DeriveFrom for Handle<T>
impl<T> DeriveFrom for Handle<T>
Source§fn derive_from(self, original: &Self, core: &mut Core) -> Self
fn derive_from(self, original: &Self, core: &mut Core) -> Self
Source§impl<T> From<Handle<T>> for HandleWrapper<T>
impl<T> From<Handle<T>> for HandleWrapper<T>
Source§impl<T> From<HandleWrapper<T>> for Handle<T>
impl<T> From<HandleWrapper<T>> for Handle<T>
Source§fn from(wrapper: HandleWrapper<T>) -> Self
fn from(wrapper: HandleWrapper<T>) -> Self
Source§impl<O> FromIterator<Handle<O>> for ObjectSet<O>
impl<O> FromIterator<Handle<O>> for ObjectSet<O>
Source§impl IsObject for Handle<HalfEdge>
impl IsObject for Handle<HalfEdge>
Source§type BareObject = HalfEdge
type BareObject = HalfEdge
Source§impl<T> Ord for Handle<T>where
T: Ord,
impl<T> Ord for Handle<T>where
T: Ord,
Source§impl<T> PartialOrd for Handle<T>where
T: PartialOrd,
impl<T> PartialOrd for Handle<T>where
T: PartialOrd,
Source§impl ReplaceCurve for Handle<Cycle>
impl ReplaceCurve for Handle<Cycle>
Source§fn replace_curve(
&self,
original: &Handle<Curve>,
replacement: Handle<Curve>,
core: &mut Core,
) -> ReplaceOutput<Self, Self::BareObject>
fn replace_curve( &self, original: &Handle<Curve>, replacement: Handle<Curve>, core: &mut Core, ) -> ReplaceOutput<Self, Self::BareObject>
Source§impl ReplaceCurve for Handle<Face>
impl ReplaceCurve for Handle<Face>
Source§fn replace_curve(
&self,
original: &Handle<Curve>,
replacement: Handle<Curve>,
core: &mut Core,
) -> ReplaceOutput<Self, Self::BareObject>
fn replace_curve( &self, original: &Handle<Curve>, replacement: Handle<Curve>, core: &mut Core, ) -> ReplaceOutput<Self, Self::BareObject>
Source§impl ReplaceCurve for Handle<HalfEdge>
impl ReplaceCurve for Handle<HalfEdge>
Source§fn replace_curve(
&self,
original: &Handle<Curve>,
replacement: Handle<Curve>,
core: &mut Core,
) -> ReplaceOutput<Self, Self::BareObject>
fn replace_curve( &self, original: &Handle<Curve>, replacement: Handle<Curve>, core: &mut Core, ) -> ReplaceOutput<Self, Self::BareObject>
Source§impl ReplaceCurve for Handle<Region>
impl ReplaceCurve for Handle<Region>
Source§fn replace_curve(
&self,
original: &Handle<Curve>,
replacement: Handle<Curve>,
core: &mut Core,
) -> ReplaceOutput<Self, Self::BareObject>
fn replace_curve( &self, original: &Handle<Curve>, replacement: Handle<Curve>, core: &mut Core, ) -> ReplaceOutput<Self, Self::BareObject>
Source§impl ReplaceCurve for Handle<Shell>
impl ReplaceCurve for Handle<Shell>
Source§fn replace_curve(
&self,
original: &Handle<Curve>,
replacement: Handle<Curve>,
core: &mut Core,
) -> ReplaceOutput<Self, Self::BareObject>
fn replace_curve( &self, original: &Handle<Curve>, replacement: Handle<Curve>, core: &mut Core, ) -> ReplaceOutput<Self, Self::BareObject>
Source§impl ReplaceCurve for Handle<Sketch>
impl ReplaceCurve for Handle<Sketch>
Source§fn replace_curve(
&self,
original: &Handle<Curve>,
replacement: Handle<Curve>,
core: &mut Core,
) -> ReplaceOutput<Self, Self::BareObject>
fn replace_curve( &self, original: &Handle<Curve>, replacement: Handle<Curve>, core: &mut Core, ) -> ReplaceOutput<Self, Self::BareObject>
Source§impl ReplaceCurve for Handle<Solid>
impl ReplaceCurve for Handle<Solid>
Source§fn replace_curve(
&self,
original: &Handle<Curve>,
replacement: Handle<Curve>,
core: &mut Core,
) -> ReplaceOutput<Self, Self::BareObject>
fn replace_curve( &self, original: &Handle<Curve>, replacement: Handle<Curve>, core: &mut Core, ) -> ReplaceOutput<Self, Self::BareObject>
Source§impl ReplaceHalfEdge for Handle<Cycle>
impl ReplaceHalfEdge for Handle<Cycle>
Source§fn replace_half_edge<const N: usize>(
&self,
original: &Handle<HalfEdge>,
replacements: [Handle<HalfEdge>; N],
core: &mut Core,
) -> ReplaceOutput<Self, Self::BareObject>
fn replace_half_edge<const N: usize>( &self, original: &Handle<HalfEdge>, replacements: [Handle<HalfEdge>; N], core: &mut Core, ) -> ReplaceOutput<Self, Self::BareObject>
Source§impl ReplaceHalfEdge for Handle<Face>
impl ReplaceHalfEdge for Handle<Face>
Source§fn replace_half_edge<const N: usize>(
&self,
original: &Handle<HalfEdge>,
replacements: [Handle<HalfEdge>; N],
core: &mut Core,
) -> ReplaceOutput<Self, Self::BareObject>
fn replace_half_edge<const N: usize>( &self, original: &Handle<HalfEdge>, replacements: [Handle<HalfEdge>; N], core: &mut Core, ) -> ReplaceOutput<Self, Self::BareObject>
Source§impl ReplaceHalfEdge for Handle<Region>
impl ReplaceHalfEdge for Handle<Region>
Source§fn replace_half_edge<const N: usize>(
&self,
original: &Handle<HalfEdge>,
replacements: [Handle<HalfEdge>; N],
core: &mut Core,
) -> ReplaceOutput<Self, Self::BareObject>
fn replace_half_edge<const N: usize>( &self, original: &Handle<HalfEdge>, replacements: [Handle<HalfEdge>; N], core: &mut Core, ) -> ReplaceOutput<Self, Self::BareObject>
Source§impl ReplaceHalfEdge for Handle<Shell>
impl ReplaceHalfEdge for Handle<Shell>
Source§fn replace_half_edge<const N: usize>(
&self,
original: &Handle<HalfEdge>,
replacements: [Handle<HalfEdge>; N],
core: &mut Core,
) -> ReplaceOutput<Self, Self::BareObject>
fn replace_half_edge<const N: usize>( &self, original: &Handle<HalfEdge>, replacements: [Handle<HalfEdge>; N], core: &mut Core, ) -> ReplaceOutput<Self, Self::BareObject>
Source§impl ReplaceHalfEdge for Handle<Sketch>
impl ReplaceHalfEdge for Handle<Sketch>
Source§fn replace_half_edge<const N: usize>(
&self,
original: &Handle<HalfEdge>,
replacements: [Handle<HalfEdge>; N],
core: &mut Core,
) -> ReplaceOutput<Self, Self::BareObject>
fn replace_half_edge<const N: usize>( &self, original: &Handle<HalfEdge>, replacements: [Handle<HalfEdge>; N], core: &mut Core, ) -> ReplaceOutput<Self, Self::BareObject>
Source§impl ReplaceHalfEdge for Handle<Solid>
impl ReplaceHalfEdge for Handle<Solid>
Source§fn replace_half_edge<const N: usize>(
&self,
original: &Handle<HalfEdge>,
replacements: [Handle<HalfEdge>; N],
core: &mut Core,
) -> ReplaceOutput<Self, Self::BareObject>
fn replace_half_edge<const N: usize>( &self, original: &Handle<HalfEdge>, replacements: [Handle<HalfEdge>; N], core: &mut Core, ) -> ReplaceOutput<Self, Self::BareObject>
Source§impl ReplaceVertex for Handle<Cycle>
impl ReplaceVertex for Handle<Cycle>
Source§fn replace_vertex(
&self,
original: &Handle<Vertex>,
replacement: Handle<Vertex>,
core: &mut Core,
) -> ReplaceOutput<Self, Self::BareObject>
fn replace_vertex( &self, original: &Handle<Vertex>, replacement: Handle<Vertex>, core: &mut Core, ) -> ReplaceOutput<Self, Self::BareObject>
Source§impl ReplaceVertex for Handle<Face>
impl ReplaceVertex for Handle<Face>
Source§fn replace_vertex(
&self,
original: &Handle<Vertex>,
replacement: Handle<Vertex>,
core: &mut Core,
) -> ReplaceOutput<Self, Self::BareObject>
fn replace_vertex( &self, original: &Handle<Vertex>, replacement: Handle<Vertex>, core: &mut Core, ) -> ReplaceOutput<Self, Self::BareObject>
Source§impl ReplaceVertex for Handle<HalfEdge>
impl ReplaceVertex for Handle<HalfEdge>
Source§fn replace_vertex(
&self,
original: &Handle<Vertex>,
replacement: Handle<Vertex>,
core: &mut Core,
) -> ReplaceOutput<Self, Self::BareObject>
fn replace_vertex( &self, original: &Handle<Vertex>, replacement: Handle<Vertex>, core: &mut Core, ) -> ReplaceOutput<Self, Self::BareObject>
Source§impl ReplaceVertex for Handle<Region>
impl ReplaceVertex for Handle<Region>
Source§fn replace_vertex(
&self,
original: &Handle<Vertex>,
replacement: Handle<Vertex>,
core: &mut Core,
) -> ReplaceOutput<Self, Self::BareObject>
fn replace_vertex( &self, original: &Handle<Vertex>, replacement: Handle<Vertex>, core: &mut Core, ) -> ReplaceOutput<Self, Self::BareObject>
Source§impl ReplaceVertex for Handle<Shell>
impl ReplaceVertex for Handle<Shell>
Source§fn replace_vertex(
&self,
original: &Handle<Vertex>,
replacement: Handle<Vertex>,
core: &mut Core,
) -> ReplaceOutput<Self, Self::BareObject>
fn replace_vertex( &self, original: &Handle<Vertex>, replacement: Handle<Vertex>, core: &mut Core, ) -> ReplaceOutput<Self, Self::BareObject>
Source§impl ReplaceVertex for Handle<Sketch>
impl ReplaceVertex for Handle<Sketch>
Source§fn replace_vertex(
&self,
original: &Handle<Vertex>,
replacement: Handle<Vertex>,
core: &mut Core,
) -> ReplaceOutput<Self, Self::BareObject>
fn replace_vertex( &self, original: &Handle<Vertex>, replacement: Handle<Vertex>, core: &mut Core, ) -> ReplaceOutput<Self, Self::BareObject>
Source§impl ReplaceVertex for Handle<Solid>
impl ReplaceVertex for Handle<Solid>
Source§fn replace_vertex(
&self,
original: &Handle<Vertex>,
replacement: Handle<Vertex>,
core: &mut Core,
) -> ReplaceOutput<Self, Self::BareObject>
fn replace_vertex( &self, original: &Handle<Vertex>, replacement: Handle<Vertex>, core: &mut Core, ) -> ReplaceOutput<Self, Self::BareObject>
Source§impl ReverseCurveCoordinateSystems for Handle<HalfEdge>
impl ReverseCurveCoordinateSystems for Handle<HalfEdge>
Source§fn reverse_curve_coordinate_systems(&self, core: &mut Core) -> Self
fn reverse_curve_coordinate_systems(&self, core: &mut Core) -> Self
Source§impl SplitHalfEdge for Handle<HalfEdge>
impl SplitHalfEdge for Handle<HalfEdge>
Source§impl SweepHalfEdge for Handle<HalfEdge>
impl SweepHalfEdge for Handle<HalfEdge>
Source§impl SweepVertex for Handle<Vertex>
impl SweepVertex for Handle<Vertex>
Source§fn sweep_vertex(
&self,
cache: &mut SweepCache,
core: &mut Core,
) -> (Handle<Curve>, Handle<Vertex>)
fn sweep_vertex( &self, cache: &mut SweepCache, core: &mut Core, ) -> (Handle<Curve>, Handle<Vertex>)
Source§impl TransformObject for Handle<HalfEdge>
impl TransformObject for Handle<HalfEdge>
Source§impl TransformObject for Handle<Surface>
impl TransformObject for Handle<Surface>
Source§impl<T> TransformObject for Handle<T>
impl<T> TransformObject for Handle<T>
Source§impl UpdateHalfEdgeGeometry for Handle<HalfEdge>
impl UpdateHalfEdgeGeometry for Handle<HalfEdge>
Source§fn set_path(self, path: SurfacePath, geometry: &mut Layer<Geometry>) -> Self
fn set_path(self, path: SurfacePath, geometry: &mut Layer<Geometry>) -> Self
Source§fn update_path(
&self,
update: impl FnOnce(SurfacePath) -> SurfacePath,
core: &mut Core,
) -> Self
fn update_path( &self, update: impl FnOnce(SurfacePath) -> SurfacePath, core: &mut Core, ) -> Self
Source§fn update_boundary(
&self,
update: impl FnOnce(CurveBoundary<Point<1>>) -> CurveBoundary<Point<1>>,
core: &mut Core,
) -> Self
fn update_boundary( &self, update: impl FnOnce(CurveBoundary<Point<1>>) -> CurveBoundary<Point<1>>, core: &mut Core, ) -> Self
impl<T> Eq for Handle<T>where
T: Eq,
impl<T> Send for Handle<T>
impl<T> Sync for Handle<T>
Auto Trait Implementations§
impl<T> Freeze for Handle<T>
impl<T> !RefUnwindSafe for Handle<T>
impl<T> Unpin for Handle<T>
impl<T> !UnwindSafe for Handle<T>
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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 moreSource§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.