pub trait Replicate:
Sync
+ Send
+ 'static
+ Named
+ Any {
Show 24 methods
// Required methods
fn kind(&self) -> ComponentKind;
fn to_any(&self) -> &dyn Any;
fn to_any_mut(&mut self) -> &mut dyn Any;
fn to_boxed_any(self: Box<Self>) -> Box<dyn Any>;
fn copy_to_box(&self) -> Box<dyn Replicate>;
fn create_builder() -> Box<dyn ReplicateBuilder>
where Self: Sized;
fn diff_mask_size(&self) -> u8;
fn dyn_ref(&self) -> ReplicaDynRef<'_>;
fn dyn_mut(&mut self) -> ReplicaDynMut<'_>;
fn mirror(&mut self, other: &dyn Replicate);
fn mirror_single_field(&mut self, field_index: u8, other: &dyn Replicate);
fn set_mutator(&mut self, mutator: &PropertyMutator);
fn write(
&self,
component_kinds: &ComponentKinds,
writer: &mut dyn BitWrite,
converter: &mut dyn LocalEntityAndGlobalEntityConverterMut,
);
fn write_update(
&self,
diff_mask: &DiffMask,
writer: &mut dyn BitWrite,
converter: &mut dyn LocalEntityAndGlobalEntityConverterMut,
);
fn read_apply_update(
&mut self,
converter: &dyn LocalEntityAndGlobalEntityConverter,
update: ComponentUpdate,
) -> Result<(), SerdeErr>;
fn read_apply_field_update(
&mut self,
converter: &dyn LocalEntityAndGlobalEntityConverter,
update: ComponentFieldUpdate,
) -> Result<(), SerdeErr>;
fn relations_waiting(&self) -> Option<HashSet<RemoteEntity>>;
fn relations_complete(
&mut self,
converter: &dyn LocalEntityAndGlobalEntityConverter,
);
fn publish(&mut self, mutator: &PropertyMutator);
fn unpublish(&mut self);
fn enable_delegation(
&mut self,
accessor: &EntityAuthAccessor,
mutator_opt: Option<&PropertyMutator>,
);
fn disable_delegation(&mut self);
fn localize(&mut self);
// Provided method
fn is_immutable(&self) -> bool { ... }
}Expand description
A struct that implements Replicate is a Component, or otherwise, a container of Properties that can be scoped, tracked, and synced, with a remote host
Required Methods§
Sourcefn kind(&self) -> ComponentKind
fn kind(&self) -> ComponentKind
Gets the ComponentKind of this type
Sourcefn to_any_mut(&mut self) -> &mut dyn Any
fn to_any_mut(&mut self) -> &mut dyn Any
Returns a mutable Any reference for downcasting.
Sourcefn to_boxed_any(self: Box<Self>) -> Box<dyn Any>
fn to_boxed_any(self: Box<Self>) -> Box<dyn Any>
Converts this boxed component into a Box<dyn Any> for downcasting.
Sourcefn copy_to_box(&self) -> Box<dyn Replicate>
fn copy_to_box(&self) -> Box<dyn Replicate>
Returns a heap-allocated clone of this component as a trait object.
Sourcefn create_builder() -> Box<dyn ReplicateBuilder>where
Self: Sized,
fn create_builder() -> Box<dyn ReplicateBuilder>where
Self: Sized,
Creates the ReplicateBuilder used to deserialize instances of this type.
Sourcefn diff_mask_size(&self) -> u8
fn diff_mask_size(&self) -> u8
Gets the number of bytes of the Component’s DiffMask
Sourcefn dyn_ref(&self) -> ReplicaDynRef<'_>
fn dyn_ref(&self) -> ReplicaDynRef<'_>
Get an immutable reference to the inner Component as a Replicate trait object
Sourcefn dyn_mut(&mut self) -> ReplicaDynMut<'_>
fn dyn_mut(&mut self) -> ReplicaDynMut<'_>
Get an mutable reference to the inner Component as a Replicate trait object
Sourcefn mirror(&mut self, other: &dyn Replicate)
fn mirror(&mut self, other: &dyn Replicate)
Sets the current Component to the state of another Component of the same type
Sourcefn mirror_single_field(&mut self, field_index: u8, other: &dyn Replicate)
fn mirror_single_field(&mut self, field_index: u8, other: &dyn Replicate)
Mirror a SINGLE Property field from other into self, identified
by its 0-based property index (the same index used by the diff-mask
bit positions). Calls Property::mirror on exactly one field —
fires that field’s PropertyMutator without touching any others.
Used by the Replicated Resources Mode B mirror system to propagate
per-field changes from the user-facing bevy Resource storage to
the entity-component without over-replicating untouched fields.
Out-of-range indices are silently no-op’d (schema evolution across protocol versions may produce stale dirty indices; we tolerate that without panicking).
Type mismatch (other is not the same concrete type as
self) is a programming error: the derive-macro impl
debug_assert!s in debug builds and silently no-ops in release.
This is hostile to ignore but a hot per-tick sync system shouldn’t
panic in production.
Sourcefn set_mutator(&mut self, mutator: &PropertyMutator)
fn set_mutator(&mut self, mutator: &PropertyMutator)
Set the Component’s PropertyMutator, which keeps track of which Properties have been mutated, necessary to sync only the Properties that have changed with the client
Sourcefn write(
&self,
component_kinds: &ComponentKinds,
writer: &mut dyn BitWrite,
converter: &mut dyn LocalEntityAndGlobalEntityConverterMut,
)
fn write( &self, component_kinds: &ComponentKinds, writer: &mut dyn BitWrite, converter: &mut dyn LocalEntityAndGlobalEntityConverterMut, )
Writes data into an outgoing byte stream, sufficient to completely recreate the Component on the client
Sourcefn write_update(
&self,
diff_mask: &DiffMask,
writer: &mut dyn BitWrite,
converter: &mut dyn LocalEntityAndGlobalEntityConverterMut,
)
fn write_update( &self, diff_mask: &DiffMask, writer: &mut dyn BitWrite, converter: &mut dyn LocalEntityAndGlobalEntityConverterMut, )
Write data into an outgoing byte stream, sufficient only to update the mutated Properties of the Component on the client
Sourcefn read_apply_update(
&mut self,
converter: &dyn LocalEntityAndGlobalEntityConverter,
update: ComponentUpdate,
) -> Result<(), SerdeErr>
fn read_apply_update( &mut self, converter: &dyn LocalEntityAndGlobalEntityConverter, update: ComponentUpdate, ) -> Result<(), SerdeErr>
Reads data from an incoming packet, sufficient to sync the in-memory Component with it’s replica on the Server
Sourcefn read_apply_field_update(
&mut self,
converter: &dyn LocalEntityAndGlobalEntityConverter,
update: ComponentFieldUpdate,
) -> Result<(), SerdeErr>
fn read_apply_field_update( &mut self, converter: &dyn LocalEntityAndGlobalEntityConverter, update: ComponentFieldUpdate, ) -> Result<(), SerdeErr>
Applies a single-field update from the network, updating the corresponding property in-place.
Sourcefn relations_waiting(&self) -> Option<HashSet<RemoteEntity>>
fn relations_waiting(&self) -> Option<HashSet<RemoteEntity>>
Returns a list of LocalEntities contained within the Component’s EntityProperty fields, which are waiting to be converted to GlobalEntities
Sourcefn relations_complete(
&mut self,
converter: &dyn LocalEntityAndGlobalEntityConverter,
)
fn relations_complete( &mut self, converter: &dyn LocalEntityAndGlobalEntityConverter, )
Converts any LocalEntities contained within the Component’s EntityProperty fields to GlobalEntities
Sourcefn publish(&mut self, mutator: &PropertyMutator)
fn publish(&mut self, mutator: &PropertyMutator)
Publish Replicate
Sourcefn enable_delegation(
&mut self,
accessor: &EntityAuthAccessor,
mutator_opt: Option<&PropertyMutator>,
)
fn enable_delegation( &mut self, accessor: &EntityAuthAccessor, mutator_opt: Option<&PropertyMutator>, )
Enable Delegation Replicate
Sourcefn disable_delegation(&mut self)
fn disable_delegation(&mut self)
Disable Delegation Replicate
Provided Methods§
Sourcefn is_immutable(&self) -> bool
fn is_immutable(&self) -> bool
Returns true if this component type never sends mutation updates.
Immutable components are written once on spawn and never diff-tracked.
Override in the derive macro by adding #[replicate(immutable)].