Skip to main content

Replicate

Trait Replicate 

Source
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§

Source

fn kind(&self) -> ComponentKind

Gets the ComponentKind of this type

Source

fn to_any(&self) -> &dyn Any

Returns a shared Any reference for downcasting.

Source

fn to_any_mut(&mut self) -> &mut dyn Any

Returns a mutable Any reference for downcasting.

Source

fn to_boxed_any(self: Box<Self>) -> Box<dyn Any>

Converts this boxed component into a Box<dyn Any> for downcasting.

Source

fn copy_to_box(&self) -> Box<dyn Replicate>

Returns a heap-allocated clone of this component as a trait object.

Source

fn create_builder() -> Box<dyn ReplicateBuilder>
where Self: Sized,

Creates the ReplicateBuilder used to deserialize instances of this type.

Source

fn diff_mask_size(&self) -> u8

Gets the number of bytes of the Component’s DiffMask

Source

fn dyn_ref(&self) -> ReplicaDynRef<'_>

Get an immutable reference to the inner Component as a Replicate trait object

Source

fn dyn_mut(&mut self) -> ReplicaDynMut<'_>

Get an mutable reference to the inner Component as a Replicate trait object

Source

fn mirror(&mut self, other: &dyn Replicate)

Sets the current Component to the state of another Component of the same type

Source

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.

Source

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

Source

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

Source

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

Source

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

Source

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.

Source

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

Source

fn relations_complete( &mut self, converter: &dyn LocalEntityAndGlobalEntityConverter, )

Converts any LocalEntities contained within the Component’s EntityProperty fields to GlobalEntities

Source

fn publish(&mut self, mutator: &PropertyMutator)

Publish Replicate

Source

fn unpublish(&mut self)

Unpublish Replicate

Source

fn enable_delegation( &mut self, accessor: &EntityAuthAccessor, mutator_opt: Option<&PropertyMutator>, )

Enable Delegation Replicate

Source

fn disable_delegation(&mut self)

Disable Delegation Replicate

Source

fn localize(&mut self)

Convert to Local Replicate

Provided Methods§

Source

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)].

Implementors§