Skip to content

Commit

Permalink
Rename register_marker_fns into set_marker_fns
Browse files Browse the repository at this point in the history
And improve the description.
  • Loading branch information
Shatur committed Apr 18, 2024
1 parent 7dde4d3 commit 5117c38
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
16 changes: 8 additions & 8 deletions src/core/command_markers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub trait AppMarkerExt {
///
/// Can be used to override how this component or other components will be written or removed
/// based on marker-component presence.
/// For details see [`Self::register_marker_fns`].
/// For details see [`Self::set_marker_fns`].
///
/// This function registers markers with priority equal to 0.
/// Use [`Self::register_marker_with_priority`] if you have multiple
Expand All @@ -30,9 +30,9 @@ pub trait AppMarkerExt {
fn register_marker_with_priority<M: Component>(&mut self, priority: usize) -> &mut Self;

/**
Associates command functions with a marker.
Associates command functions with a marker for a component.
If this component is present on an entity and its priority is the highest,
If this marker is present on an entity and its priority is the highest,
then these functions will be called for this component during replication
instead of default [`write`](super::replication_fns::command_fns::write) and
[`remove`](super::replication_fns::command_fns::remove).
Expand Down Expand Up @@ -68,7 +68,7 @@ pub trait AppMarkerExt {
app.register_marker::<ComponentsHistory>();
// SAFETY: `write_history` can be safely called with a `SerdeFns` created for `Transform`.
unsafe {
app.register_marker_fns::<ComponentsHistory, Transform>(
app.set_marker_fns::<ComponentsHistory, Transform>(
write_history::<Transform>,
command_fns::remove::<Transform>,
);
Expand Down Expand Up @@ -117,7 +117,7 @@ pub trait AppMarkerExt {
struct History<C>(Vec<C>);
```
**/
unsafe fn register_marker_fns<M: Component, C: Component>(
unsafe fn set_marker_fns<M: Component, C: Component>(
&mut self,
write: WriteFn,
remove: RemoveFn,
Expand All @@ -143,7 +143,7 @@ impl AppMarkerExt for App {
self
}

unsafe fn register_marker_fns<M: Component, C: Component>(
unsafe fn set_marker_fns<M: Component, C: Component>(
&mut self,
write: WriteFn,
remove: RemoveFn,
Expand All @@ -154,7 +154,7 @@ impl AppMarkerExt for App {
self.world
.resource_scope(|world, mut replication_fns: Mut<ReplicationFns>| unsafe {
// SAFETY: The caller ensured that `write` can be safely called with a `SerdeFns` created for `C`.
replication_fns.register_marker_fns::<C>(world, marker_id, write, remove);
replication_fns.set_marker_fns::<C>(world, marker_id, write, remove);
});

self
Expand Down Expand Up @@ -230,7 +230,7 @@ mod tests {

// SAFETY: `write` can be safely called with a `SerdeFns` created for `DummyComponent`.
unsafe {
app.register_marker_fns::<DummyMarkerA, DummyComponent>(
app.set_marker_fns::<DummyMarkerA, DummyComponent>(
command_fns::write::<DummyComponent>,
command_fns::remove::<DummyComponent>,
);
Expand Down
10 changes: 5 additions & 5 deletions src/core/replication_fns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl ReplicationFns {
}
}

/// Associates command functions with a marker.
/// Associates command functions with a marker for a component.
///
/// **Must** be called **after** calling [`Self::register_marker`] with `marker_id`.
///
Expand All @@ -62,7 +62,7 @@ impl ReplicationFns {
/// # Panics
///
/// Panics if the marker wasn't registered. Use [`Self::register_marker`] first.
pub(super) unsafe fn register_marker_fns<C: Component>(
pub(super) unsafe fn set_marker_fns<C: Component>(
&mut self,
world: &mut World,
marker_id: CommandMarkerId,
Expand Down Expand Up @@ -226,7 +226,7 @@ mod tests {

// SAFETY: `write` can be safely called with a `SerdeFns` created for `ComponentA`.
unsafe {
replication_fns.register_marker_fns::<ComponentA>(
replication_fns.set_marker_fns::<ComponentA>(
&mut world,
marker_a,
command_fns::write::<ComponentA>,
Expand Down Expand Up @@ -260,13 +260,13 @@ mod tests {
// SAFETY: `write` can be safely called with `SerdeFns` for
// `ComponentA` and `ComponentA` for each call respectively.
unsafe {
replication_fns.register_marker_fns::<ComponentA>(
replication_fns.set_marker_fns::<ComponentA>(
&mut world,
marker_a,
command_fns::write::<ComponentA>,
command_fns::remove::<ComponentA>,
);
replication_fns.register_marker_fns::<ComponentB>(
replication_fns.set_marker_fns::<ComponentB>(
&mut world,
marker_b,
command_fns::write::<ComponentB>,
Expand Down
2 changes: 1 addition & 1 deletion tests/changes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ fn marker() {

// SAFETY: `replace` can be safely called with a `SerdeFns` created for `OriginalComponent`.
unsafe {
app.register_marker_fns::<ReplaceMarker, OriginalComponent>(
app.set_marker_fns::<ReplaceMarker, OriginalComponent>(
replace,
command_fns::remove::<ReplacedComponent>,
);
Expand Down
2 changes: 1 addition & 1 deletion tests/insertion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ fn marker() {

// SAFETY: `replace` can be safely called with a `SerdeFns` created for `OriginalComponent`.
unsafe {
app.register_marker_fns::<ReplaceMarker, OriginalComponent>(
app.set_marker_fns::<ReplaceMarker, OriginalComponent>(
replace,
command_fns::remove::<ReplacedComponent>,
);
Expand Down
2 changes: 1 addition & 1 deletion tests/removal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ fn marker() {

// SAFETY: `replace` can be safely called with a `SerdeFns` created for `DummyComponent`.
unsafe {
app.register_marker_fns::<RemoveMarker, DummyComponent>(
app.set_marker_fns::<RemoveMarker, DummyComponent>(
command_fns::write::<DummyComponent>,
command_fns::remove::<RemovingComponent>,
);
Expand Down

0 comments on commit 5117c38

Please sign in to comment.