pub struct BelongsTo<T> { /* private fields */ }Expand description
Represents a “belongs-to” navigation - ?the dependent side of a one-to-many or one-to-one relationship where the foreign key lives on this entity.
Corresponds to EFCore’s reference navigation property.
Implementations§
Source§impl<T> BelongsTo<T>
impl<T> BelongsTo<T>
pub fn new() -> Self
pub fn with(entity: T) -> Self
pub fn get(&self) -> Option<&T>
pub fn get_mut(&mut self) -> Option<&mut T>
Sourcepub fn is_loaded(&self) -> bool
pub fn is_loaded(&self) -> bool
Returns true if the navigation has been loaded (either eagerly
via Include or lazily via [load]).
Sourcepub fn set_lazy_context(&mut self, ctx: Arc<dyn LazyContext>)
pub fn set_lazy_context(&mut self, ctx: Arc<dyn LazyContext>)
Attaches a lazy-loading context to this container.
Called by the #[derive(EntityType)] macro’s ILazyInit
implementation when lazy loading is enabled on the DbContext.
Sourcepub async fn load(&mut self) -> EFResult<()>
pub async fn load(&mut self) -> EFResult<()>
Triggers lazy loading of this reference navigation.
If the navigation is already loaded, this is a no-op. If no
LazyContext is attached (lazy loading disabled), returns
Ok(()) without loading.
After this call, [get] returns the loaded entity (or None if
no matching row was found).
Trait Implementations§
Auto Trait Implementations§
impl<T> !RefUnwindSafe for BelongsTo<T>
impl<T> !UnwindSafe for BelongsTo<T>
impl<T> Freeze for BelongsTo<T>
impl<T> Send for BelongsTo<T>where
T: Send,
impl<T> Sync for BelongsTo<T>where
T: Sync,
impl<T> Unpin for BelongsTo<T>where
T: Unpin,
impl<T> UnsafeUnpin for BelongsTo<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
Mutably borrows from an owned value. Read more