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 Handle
s, 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<T> Ord for Handle<T>where
T: Ord,
impl<T> Ord for Handle<T>where
T: Ord,
source§impl<T> PartialEq for Handle<T>where
T: PartialEq,
impl<T> PartialEq for Handle<T>where
T: PartialEq,
source§impl<T> PartialOrd for Handle<T>where
T: PartialOrd,
impl<T> PartialOrd for Handle<T>where
T: PartialOrd,
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§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> 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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§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.