Skip to content

Commit

Permalink
doc: update GgrsEvent, GgrsRequest and GgrsError names in docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
gschup committed Nov 10, 2023
1 parent 63e047d commit 1265cbc
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 30 deletions.
8 changes: 4 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ In this document, all remarkable changes are listed. Not mentioned are smaller c

## 0.4.2

- users are now allowed to save `None` buffers for a `GGRSRequest::SaveRequest`. This allows users to keep their own state history and load/save more efficiently
- users are now allowed to save `None` buffers for a `GgrsRequest::SaveRequest`. This allows users to keep their own state history and load/save more efficiently
- added `num_players()`, `input_size()` getters to all sessions

## 0.4.1
Expand All @@ -117,8 +117,8 @@ In this document, all remarkable changes are listed. Not mentioned are smaller c

## 0.3.0

- `GGRSError::InvalidRequest` now has an added `info` field to explain the problem in more detail
- removed unused `GGRSError::GeneralFailure`
- `GgrsError::InvalidRequest` now has an added `info` field to explain the problem in more detail
- removed unused `GgrsError::GeneralFailure`
- removed multiple methods in `SyncTestSession`, as they didn't fulfill any meaningful purpose
- removed unused sequence number from message header, fixing related issues
- fixed an issue where out-of-order packets would cause a crash
Expand Down Expand Up @@ -152,4 +152,4 @@ In this document, all remarkable changes are listed. Not mentioned are smaller c

## 0.2.0

- Reworked API: Instead of the user passing a GGRSInterface trait object, GGRS now returns a list of GGRSRequests for the user to fulfill
- Reworked API: Instead of the user passing a GGRSInterface trait object, GGRS now returns a list of GgrsRequests for the user to fulfill
2 changes: 1 addition & 1 deletion examples/ex_game/ex_game.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ fn fletcher16(data: &[u8]) -> u16 {
(sum2 << 8) | sum1
}

// BoxGame will handle rendering, gamestate, inputs and GGRSRequests
// BoxGame will handle rendering, gamestate, inputs and GgrsRequests
pub struct Game {
num_players: usize,
game_state: State,
Expand Down
4 changes: 2 additions & 2 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ use std::fmt::Display;

use crate::Frame;

/// This enum contains all error messages this library can return. Most API functions will generally return a [`Result<(),GGRSError>`].
/// This enum contains all error messages this library can return. Most API functions will generally return a [`Result<(),GgrsError>`].
///
/// [`Result<(),GGRSError>`]: std::result::Result
/// [`Result<(),GgrsError>`]: std::result::Result
#[derive(Debug, Clone, PartialEq, Hash)]
pub enum GgrsError {
/// When the prediction threshold has been reached, we cannot accept more inputs from the local player.
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ where
/// The client will be disconnected in this amount of ms.
disconnect_timeout: u128,
},
/// Sent only after a [`GGRSEvent::NetworkInterrupted`] event, if communication with that player has resumed.
/// Sent only after a [`GgrsEvent::NetworkInterrupted`] event, if communication with that player has resumed.
NetworkResumed {
/// The address of the endpoint.
addr: T::Address,
Expand Down
8 changes: 4 additions & 4 deletions src/sessions/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl<T: Config> SessionBuilder<T> {
/// - Returns [`InvalidRequest`] if a player with that handle has been added before
/// - Returns [`InvalidRequest`] if the handle is invalid for the given [`PlayerType`]
///
/// [`InvalidRequest`]: GGRSError::InvalidRequest
/// [`InvalidRequest`]: GgrsError::InvalidRequest
/// [`num_players`]: Self#structfield.num_players
pub fn add_player(
mut self,
Expand Down Expand Up @@ -132,7 +132,7 @@ impl<T: Config> SessionBuilder<T> {
/// # Errors
/// - Returns [`InvalidRequest`] if the prediction window is 0.
///
/// [`InvalidRequest`]: GGRSError::InvalidRequest
/// [`InvalidRequest`]: GgrsError::InvalidRequest
pub fn with_max_prediction_window(mut self, window: usize) -> Result<Self, GgrsError> {
if window == 0 {
return Err(GgrsError::InvalidRequest {
Expand Down Expand Up @@ -187,7 +187,7 @@ impl<T: Config> SessionBuilder<T> {
/// # Errors
/// - Returns [`InvalidRequest`] if the fps is 0
///
/// [`InvalidRequest`]: GGRSError::InvalidRequest
/// [`InvalidRequest`]: GgrsError::InvalidRequest
pub fn with_fps(mut self, fps: usize) -> Result<Self, GgrsError> {
if fps == 0 {
return Err(GgrsError::InvalidRequest {
Expand Down Expand Up @@ -247,7 +247,7 @@ impl<T: Config> SessionBuilder<T> {
/// # Errors
/// - Returns [`InvalidRequest`] if insufficient players have been registered.
///
/// [`InvalidRequest`]: GGRSError::InvalidRequest
/// [`InvalidRequest`]: GgrsError::InvalidRequest
pub fn start_p2p_session(
mut self,
socket: impl NonBlockingSocket<T::Address> + 'static,
Expand Down
18 changes: 9 additions & 9 deletions src/sessions/p2p_session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ where

/// notes which inputs have already been sent to the spectators
next_spectator_frame: Frame,
/// The soonest frame on which the session can send a [`GGRSEvent::WaitRecommendation`] again.
/// The soonest frame on which the session can send a [`GgrsEvent::WaitRecommendation`] again.
next_recommended_sleep: Frame,
/// How many frames we estimate we are ahead of every remote client
frames_ahead: i32,
Expand Down Expand Up @@ -220,7 +220,7 @@ impl<T: Config> P2PSession<T> {
/// - Returns [`InvalidRequest`] when the given handle does not refer to a local player.
///
/// [`advance_frame()`]: Self#method.advance_frame
/// [`InvalidRequest`]: GGRSError::InvalidRequest
/// [`InvalidRequest`]: GgrsError::InvalidRequest
pub fn add_local_input(
&mut self,
player_handle: PlayerHandle,
Expand All @@ -243,16 +243,16 @@ impl<T: Config> P2PSession<T> {
}

/// You should call this to notify GGRS that you are ready to advance your gamestate by a single frame.
/// Returns an order-sensitive [`Vec<GGRSRequest>`]. You should fulfill all requests in the exact order they are provided.
/// Returns an order-sensitive [`Vec<GgrsRequest>`]. You should fulfill all requests in the exact order they are provided.
/// Failure to do so will cause panics later.
///
/// # Errors
/// - Returns [`InvalidRequest`] if the provided player handle refers to a remote player.
/// - Returns [`NotSynchronized`] if the session is not yet ready to accept input. In this case, you either need to start the session or wait for synchronization between clients.
///
/// [`Vec<GGRSRequest>`]: GGRSRequest
/// [`InvalidRequest`]: GGRSError::InvalidRequest
/// [`NotSynchronized`]: GGRSError::NotSynchronized
/// [`Vec<GgrsRequest>`]: GgrsRequest
/// [`InvalidRequest`]: GgrsError::InvalidRequest
/// [`NotSynchronized`]: GgrsError::NotSynchronized
pub fn advance_frame(&mut self) -> Result<Vec<GgrsRequest<T>>, GgrsError> {
// receive info from remote players, trigger events and send messages
self.poll_remote_clients();
Expand Down Expand Up @@ -429,7 +429,7 @@ impl<T: Config> P2PSession<T> {
/// # Errors
/// - Returns [`InvalidRequest`] if you try to disconnect a local player or the provided handle is invalid.
///
/// [`InvalidRequest`]: GGRSError::InvalidRequest
/// [`InvalidRequest`]: GgrsError::InvalidRequest
pub fn disconnect_player(&mut self, player_handle: PlayerHandle) -> Result<(), GgrsError> {
match self.player_reg.handles.get(&player_handle) {
// the local player cannot be disconnected
Expand Down Expand Up @@ -463,8 +463,8 @@ impl<T: Config> P2PSession<T> {
/// - Returns [`InvalidRequest`] if the handle not referring to a remote player or spectator.
/// - Returns [`NotSynchronized`] if the session is not connected to other clients yet.
///
/// [`InvalidRequest`]: GGRSError::InvalidRequest
/// [`NotSynchronized`]: GGRSError::NotSynchronized
/// [`InvalidRequest`]: GgrsError::InvalidRequest
/// [`NotSynchronized`]: GgrsError::NotSynchronized
pub fn network_stats(&self, player_handle: PlayerHandle) -> Result<NetworkStats, GgrsError> {
match self.player_reg.handles.get(&player_handle) {
Some(PlayerType::Remote(addr)) => self
Expand Down
8 changes: 4 additions & 4 deletions src/sessions/p2p_spectator_session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl<T: Config> SpectatorSession<T> {
/// # Errors
/// - Returns [`NotSynchronized`] if the session is not connected to other clients yet.
///
/// [`NotSynchronized`]: GGRSError::NotSynchronized
/// [`NotSynchronized`]: GgrsError::NotSynchronized
pub fn network_stats(&self) -> Result<NetworkStats, GgrsError> {
self.host.network_stats()
}
Expand All @@ -98,14 +98,14 @@ impl<T: Config> SpectatorSession<T> {
}

/// You should call this to notify GGRS that you are ready to advance your gamestate by a single frame.
/// Returns an order-sensitive [`Vec<GGRSRequest>`]. You should fulfill all requests in the exact order they are provided.
/// Returns an order-sensitive [`Vec<GgrsRequest>`]. You should fulfill all requests in the exact order they are provided.
/// Failure to do so will cause panics later.
/// # Errors
/// - Returns [`NotSynchronized`] if the session is not yet ready to accept input.
/// In this case, you either need to start the session or wait for synchronization between clients.
///
/// [`Vec<GGRSRequest>`]: GGRSRequest
/// [`NotSynchronized`]: GGRSError::NotSynchronized
/// [`Vec<GgrsRequest>`]: GgrsRequest
/// [`NotSynchronized`]: GgrsError::NotSynchronized
pub fn advance_frame(&mut self) -> Result<Vec<GgrsRequest<T>>, GgrsError> {
// receive info from host, trigger events and send messages
self.poll_remote_clients();
Expand Down
8 changes: 4 additions & 4 deletions src/sessions/sync_test_session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl<T: Config> SyncTestSession<T> {
/// - Returns [`InvalidRequest`] when the given handle is not valid (i.e. not between 0 and num_players).
///
/// [`advance_frame()`]: Self#method.advance_frame
/// [`InvalidRequest`]: GGRSError::InvalidRequest
/// [`InvalidRequest`]: GgrsError::InvalidRequest
pub fn add_local_input(
&mut self,
player_handle: PlayerHandle,
Expand All @@ -74,14 +74,14 @@ impl<T: Config> SyncTestSession<T> {
}

/// In a sync test, this will advance the state by a single frame and afterwards rollback `check_distance` amount of frames,
/// resimulate and compare checksums with the original states. Returns an order-sensitive [`Vec<GGRSRequest>`].
/// resimulate and compare checksums with the original states. Returns an order-sensitive [`Vec<GgrsRequest>`].
/// You should fulfill all requests in the exact order they are provided. Failure to do so will cause panics later.
///
/// # Errors
/// - Returns [`MismatchedChecksum`] if checksums don't match after resimulation.
///
/// [`Vec<GGRSRequest>`]: GGRSRequest
/// [`MismatchedChecksum`]: GGRSError::MismatchedChecksum
/// [`Vec<GgrsRequest>`]: GgrsRequest
/// [`MismatchedChecksum`]: GgrsError::MismatchedChecksum
pub fn advance_frame(&mut self) -> Result<Vec<GgrsRequest<T>>, GgrsError> {
let mut requests = Vec::new();

Expand Down
2 changes: 1 addition & 1 deletion src/sync_layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::input_queue::InputQueue;
use crate::network::messages::ConnectionStatus;
use crate::{Config, Frame, GgrsRequest, InputStatus, PlayerHandle, NULL_FRAME};

/// An [`Arc<Mutex>`] that you can [`save()`]/[`load()`] a `T` to/from. These will be handed to the user as part of a [`GGRSRequest`].
/// An [`Arc<Mutex>`] that you can [`save()`]/[`load()`] a `T` to/from. These will be handed to the user as part of a [`GgrsRequest`].
///
/// [`save()`]: GameStateCell#method.save
/// [`load()`]: GameStateCell#method.load
Expand Down

0 comments on commit 1265cbc

Please sign in to comment.