Struct fj_core::storage::Handle

source ·
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§

source§

impl<T> Handle<T>

source

pub fn id(&self) -> ObjectId

Access the object’s unique id

source

pub fn clone_object(&self) -> T
where T: Clone,

Return a bare object, which is a clone of the referenced stored object

Trait Implementations§

source§

impl<T> Borrow<T> for Handle<T>

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl BoundingVolume<2> for Handle<HalfEdge>

source§

fn aabb(&self, geometry: &Geometry) -> Option<Aabb<2>>

Compute an axis-aligned bounding box (AABB) Read more
source§

impl<T> Clone for Handle<T>

source§

fn clone(&self) -> Self

Returns a copy 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<T> Debug for Handle<T>
where T: Debug,

source§

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

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

impl<T> Deref for Handle<T>

§

type Target = T

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<T> DeriveFrom for Handle<T>
where Self: Into<AnyObject<Stored>>,

source§

fn derive_from(self, original: &Self, core: &mut Core) -> Self

Mark this object as derived from the other object provided
source§

impl From<Handle<Curve>> for AnyObject<Stored>

source§

fn from(object: Handle<Curve>) -> Self

Converts to this type from the input type.
source§

impl From<Handle<Cycle>> for AnyObject<Stored>

source§

fn from(object: Handle<Cycle>) -> Self

Converts to this type from the input type.
source§

impl From<Handle<Face>> for AnyObject<Stored>

source§

fn from(object: Handle<Face>) -> Self

Converts to this type from the input type.
source§

impl From<Handle<HalfEdge>> for AnyObject<Stored>

source§

fn from(object: Handle<HalfEdge>) -> Self

Converts to this type from the input type.
source§

impl From<Handle<Region>> for AnyObject<Stored>

source§

fn from(object: Handle<Region>) -> Self

Converts to this type from the input type.
source§

impl From<Handle<Shell>> for AnyObject<Stored>

source§

fn from(object: Handle<Shell>) -> Self

Converts to this type from the input type.
source§

impl From<Handle<Sketch>> for AnyObject<Stored>

source§

fn from(object: Handle<Sketch>) -> Self

Converts to this type from the input type.
source§

impl From<Handle<Solid>> for AnyObject<Stored>

source§

fn from(object: Handle<Solid>) -> Self

Converts to this type from the input type.
source§

impl From<Handle<Surface>> for AnyObject<Stored>

source§

fn from(object: Handle<Surface>) -> Self

Converts to this type from the input type.
source§

impl<T> From<Handle<T>> for HandleWrapper<T>

source§

fn from(handle: Handle<T>) -> Self

Converts to this type from the input type.
source§

impl From<Handle<Vertex>> for AnyObject<Stored>

source§

fn from(object: Handle<Vertex>) -> Self

Converts to this type from the input type.
source§

impl<T> From<HandleWrapper<T>> for Handle<T>

source§

fn from(wrapper: HandleWrapper<T>) -> Self

Converts to this type from the input type.
source§

impl<O> FromIterator<Handle<O>> for ObjectSet<O>
where O: Debug + Ord,

source§

fn from_iter<T: IntoIterator<Item = Handle<O>>>(handles: T) -> Self

Creates a value from an iterator. Read more
source§

impl GetColor for Handle<Region>

source§

fn get_color(&self, core: &mut Core) -> Option<Color>

Get the color of the object
source§

impl<T> Hash for Handle<T>
where T: Hash,

source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<T> Insert for Handle<T>
where T: Insert,

§

type Inserted = Handle<T>

The type of Self, once it has been inserted Read more
source§

fn insert(self, _: &mut Core) -> Self::Inserted

Insert the object into its respective store Read more
source§

impl IsObject for Handle<Curve>

§

type BareObject = Curve

The type of the bare object
source§

impl IsObject for Handle<Cycle>

§

type BareObject = Cycle

The type of the bare object
source§

impl IsObject for Handle<Face>

§

type BareObject = Face

The type of the bare object
source§

impl IsObject for Handle<HalfEdge>

§

type BareObject = HalfEdge

The type of the bare object
source§

impl IsObject for Handle<Region>

§

type BareObject = Region

The type of the bare object
source§

impl IsObject for Handle<Shell>

§

type BareObject = Shell

The type of the bare object
source§

impl IsObject for Handle<Sketch>

§

type BareObject = Sketch

The type of the bare object
source§

impl IsObject for Handle<Solid>

§

type BareObject = Solid

The type of the bare object
source§

impl IsObject for Handle<Surface>

§

type BareObject = Surface

The type of the bare object
source§

impl IsObject for Handle<Vertex>

§

type BareObject = Vertex

The type of the bare object
source§

impl<T> Ord for Handle<T>
where T: Ord,

source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl<T> PartialEq for Handle<T>
where T: PartialEq,

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T> PartialOrd for Handle<T>
where T: PartialOrd,

source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl ReplaceCurve for Handle<Cycle>

source§

fn replace_curve( &self, original: &Handle<Curve>, replacement: Handle<Curve>, core: &mut Core ) -> ReplaceOutput<Self, Self::BareObject>

Replace the curve
source§

impl ReplaceCurve for Handle<Face>

source§

fn replace_curve( &self, original: &Handle<Curve>, replacement: Handle<Curve>, core: &mut Core ) -> ReplaceOutput<Self, Self::BareObject>

Replace the curve
source§

impl ReplaceCurve for Handle<HalfEdge>

source§

fn replace_curve( &self, original: &Handle<Curve>, replacement: Handle<Curve>, core: &mut Core ) -> ReplaceOutput<Self, Self::BareObject>

Replace the curve
source§

impl ReplaceCurve for Handle<Region>

source§

fn replace_curve( &self, original: &Handle<Curve>, replacement: Handle<Curve>, core: &mut Core ) -> ReplaceOutput<Self, Self::BareObject>

Replace the curve
source§

impl ReplaceCurve for Handle<Shell>

source§

fn replace_curve( &self, original: &Handle<Curve>, replacement: Handle<Curve>, core: &mut Core ) -> ReplaceOutput<Self, Self::BareObject>

Replace the curve
source§

impl ReplaceCurve for Handle<Sketch>

source§

fn replace_curve( &self, original: &Handle<Curve>, replacement: Handle<Curve>, core: &mut Core ) -> ReplaceOutput<Self, Self::BareObject>

Replace the curve
source§

impl ReplaceCurve for Handle<Solid>

source§

fn replace_curve( &self, original: &Handle<Curve>, replacement: Handle<Curve>, core: &mut Core ) -> ReplaceOutput<Self, Self::BareObject>

Replace the curve
source§

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>

Replace the half-edge
source§

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>

Replace the half-edge
source§

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>

Replace the half-edge
source§

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>

Replace the half-edge
source§

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>

Replace the half-edge
source§

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>

Replace the half-edge
source§

impl ReplaceVertex for Handle<Cycle>

source§

fn replace_vertex( &self, original: &Handle<Vertex>, replacement: Handle<Vertex>, core: &mut Core ) -> ReplaceOutput<Self, Self::BareObject>

Replace the vertex
source§

impl ReplaceVertex for Handle<Face>

source§

fn replace_vertex( &self, original: &Handle<Vertex>, replacement: Handle<Vertex>, core: &mut Core ) -> ReplaceOutput<Self, Self::BareObject>

Replace the vertex
source§

impl ReplaceVertex for Handle<HalfEdge>

source§

fn replace_vertex( &self, original: &Handle<Vertex>, replacement: Handle<Vertex>, core: &mut Core ) -> ReplaceOutput<Self, Self::BareObject>

Replace the vertex
source§

impl ReplaceVertex for Handle<Region>

source§

fn replace_vertex( &self, original: &Handle<Vertex>, replacement: Handle<Vertex>, core: &mut Core ) -> ReplaceOutput<Self, Self::BareObject>

Replace the vertex
source§

impl ReplaceVertex for Handle<Shell>

source§

fn replace_vertex( &self, original: &Handle<Vertex>, replacement: Handle<Vertex>, core: &mut Core ) -> ReplaceOutput<Self, Self::BareObject>

Replace the vertex
source§

impl ReplaceVertex for Handle<Sketch>

source§

fn replace_vertex( &self, original: &Handle<Vertex>, replacement: Handle<Vertex>, core: &mut Core ) -> ReplaceOutput<Self, Self::BareObject>

Replace the vertex
source§

impl ReplaceVertex for Handle<Solid>

source§

fn replace_vertex( &self, original: &Handle<Vertex>, replacement: Handle<Vertex>, core: &mut Core ) -> ReplaceOutput<Self, Self::BareObject>

Replace the vertex
source§

impl ReverseCurveCoordinateSystems for Handle<HalfEdge>

source§

fn reverse_curve_coordinate_systems(&self, core: &mut Core) -> Self

Reverse the direction of the curve coordinate systems within an object Read more
source§

impl SetColor for Handle<Region>

source§

fn set_color(&self, color: impl Into<Color>, core: &mut Core)

Set the color of the object
source§

impl SplitHalfEdge for Handle<HalfEdge>

source§

fn split_half_edge( &self, point: impl Into<Point<1>>, core: &mut Core ) -> [Handle<HalfEdge>; 2]

Split the half-edge into two Read more
source§

impl SweepFace for Handle<Face>

source§

fn sweep_face( &self, path: impl Into<Vector<3>>, cache: &mut SweepCache, core: &mut Core ) -> Shell

Sweep the Face into a Shell Read more
source§

impl SweepHalfEdge for Handle<HalfEdge>

source§

fn sweep_half_edge( &self, end_vertex: Handle<Vertex>, surface: &SurfaceGeometry, color: Option<Color>, path: impl Into<Vector<3>>, cache: &mut SweepCache, core: &mut Core ) -> (Face, Handle<HalfEdge>)

source§

impl SweepVertex for Handle<Vertex>

source§

fn sweep_vertex( &self, cache: &mut SweepCache, core: &mut Core ) -> (Handle<Curve>, Handle<Vertex>)

Sweep the vertex Read more
source§

impl TransformObject for Handle<HalfEdge>

source§

fn transform_with_cache( &self, transform: &Transform, core: &mut Core, cache: &mut TransformCache ) -> Self

Transform the object using the provided cache
source§

fn transform(&self, transform: &Transform, core: &mut Core) -> Self

Transform the object
source§

fn translate(&self, offset: impl Into<Vector<3>>, core: &mut Core) -> Self

Translate the object Read more
source§

fn rotate(&self, axis_angle: impl Into<Vector<3>>, core: &mut Core) -> Self

Rotate the object Read more
source§

impl TransformObject for Handle<Surface>

source§

fn transform_with_cache( &self, transform: &Transform, core: &mut Core, cache: &mut TransformCache ) -> Self

Transform the object using the provided cache
source§

fn transform(&self, transform: &Transform, core: &mut Core) -> Self

Transform the object
source§

fn translate(&self, offset: impl Into<Vector<3>>, core: &mut Core) -> Self

Translate the object Read more
source§

fn rotate(&self, axis_angle: impl Into<Vector<3>>, core: &mut Core) -> Self

Rotate the object Read more
source§

impl<T> TransformObject for Handle<T>
where T: Clone + Insert<Inserted = Handle<T>> + TransformObject + 'static, Handle<T>: Into<AnyObject<Stored>>,

source§

fn transform_with_cache( &self, transform: &Transform, core: &mut Core, cache: &mut TransformCache ) -> Self

Transform the object using the provided cache
source§

fn transform(&self, transform: &Transform, core: &mut Core) -> Self

Transform the object
source§

fn translate(&self, offset: impl Into<Vector<3>>, core: &mut Core) -> Self

Translate the object Read more
source§

fn rotate(&self, axis_angle: impl Into<Vector<3>>, core: &mut Core) -> Self

Rotate the object Read more
source§

impl UpdateHalfEdgeGeometry for Handle<HalfEdge>

source§

fn set_path(self, path: SurfacePath, geometry: &mut Layer<Geometry>) -> Self

Set the path of the half-edge
source§

fn update_path( &self, update: impl FnOnce(SurfacePath) -> SurfacePath, core: &mut Core ) -> Self

Update the path of the half-edge
source§

fn update_boundary( &self, update: impl FnOnce(CurveBoundary<Point<1>>) -> CurveBoundary<Point<1>>, core: &mut Core ) -> Self

Update the boundary of the half-edge
source§

impl<T> Eq for Handle<T>
where T: Eq,

source§

impl<T> Send for Handle<T>

source§

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
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<T> Downcast for T
where T: Any,

source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &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
where T: Any + Send + Sync,

source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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> Same for T

§

type Output = T

Should always be Self
source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
source§

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

§

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>,

§

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>,

§

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> Scalar for T
where T: 'static + Clone + PartialEq + Debug,