#[non_exhaustive]pub struct MagnetRef {
pub id: MagnetId,
pub item: ItemId,
pub role: MagnetRole,
pub payload: Option<Rc<dyn Any>>,
pub scene_pos: Point,
}Expand description
An owned, borrow-free snapshot of one magnet, handed to the
accept/reject predicate and carried in a MagnetConnection.
The payload is an Rc clone, so a snapshot can outlive the borrow
taken to collect candidates. The predicate inspects these snapshots
while a shared (read-only) scene borrow is held — it may read the
model but must not mutate it. The on_connect handler, by contrast,
runs after every borrow is dropped and may freely mutate the model
(add an edge item, reparent, fire an intent).
#[non_exhaustive]: the crate hands this to consumer code — it is what a
predicate inspects — the same reason MagnetVisualState carries it. Build
one with new.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.id: MagnetIdThe magnet’s id.
item: ItemIdThe item the magnet is attached to.
role: MagnetRoleThe magnet’s advisory direction.
payload: Option<Rc<dyn Any>>The magnet’s payload, if any (an Rc clone of the stored one).
scene_pos: PointThe magnet’s current position in scene coordinates.
Implementations§
Source§impl MagnetRef
impl MagnetRef
Sourcepub fn new(
id: MagnetId,
item: ItemId,
role: MagnetRole,
payload: Option<Rc<dyn Any>>,
scene_pos: Point,
) -> Self
pub fn new( id: MagnetId, item: ItemId, role: MagnetRole, payload: Option<Rc<dyn Any>>, scene_pos: Point, ) -> Self
A snapshot stated field by field — the constructor
#[non_exhaustive] takes the place of a struct literal for.
The scene builds its own; this is for a consumer testing its predicate.
Sourcepub fn payload_as<P: 'static>(&self) -> Option<&P>
pub fn payload_as<P: 'static>(&self) -> Option<&P>
Borrow the payload downcast to P, or None if absent or a
different type. The ergonomic way to read a typed payload inside
a predicate.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for MagnetRef
impl !Send for MagnetRef
impl !Sync for MagnetRef
impl !UnwindSafe for MagnetRef
impl Freeze for MagnetRef
impl Unpin for MagnetRef
impl UnsafeUnpin for MagnetRef
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§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.§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.§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.§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.impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
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