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 const fn is_dirty(&self) -> bool
pub const fn is_dirty(&self) -> bool
Returns true if the value has been modified since last sync.
Sourcepub const fn clear_dirty(&mut self)
pub const 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§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> ⓘ
Converts
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> ⓘ
Converts
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 moreWraps this value in an
Arc<SyncMutex<>>