pub struct SyncedValue<T> {
value: T,
default: T,
dirty: bool,
}Expand description
Wrapper that tracks modifications per-field.
Each field in an entity data struct is wrapped in SyncedValue to track
whether it has been modified and needs to be synced to clients.
Fields§
§value: T§default: T§dirty: boolImplementations§
Source§impl<T: Clone + PartialEq> SyncedValue<T>
impl<T: Clone + PartialEq> SyncedValue<T>
Sourcepub fn set(&mut self, value: T)
pub fn set(&mut self, value: T)
Set the value. Only marks as dirty if the value actually changed.
Sourcepub fn clear_dirty(&mut self)
pub fn clear_dirty(&mut self)
Clear the dirty flag after syncing.
Sourcepub fn is_default(&self) -> bool
pub fn is_default(&self) -> bool
Returns true if the current value equals the default.
Trait Implementations§
Source§impl<T: Clone> Clone for SyncedValue<T>
impl<T: Clone> Clone for SyncedValue<T>
Source§fn clone(&self) -> SyncedValue<T>
fn clone(&self) -> SyncedValue<T>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl<T> Freeze for SyncedValue<T>where
T: Freeze,
impl<T> RefUnwindSafe for SyncedValue<T>where
T: RefUnwindSafe,
impl<T> Send for SyncedValue<T>where
T: Send,
impl<T> Sync for SyncedValue<T>where
T: Sync,
impl<T> Unpin for SyncedValue<T>where
T: Unpin,
impl<T> UnsafeUnpin for SyncedValue<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for SyncedValue<T>where
T: UnwindSafe,
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