Skip to main content

Crate api

Crate api 

Source
Expand description

§api

This crate exposes the HTTP API for the game server. Its main responsibilities are:

  1. Exposing HTTP endpoints for clients (web or other consumers).
  2. Providing DTOs (Data Transfer Objects) for communication.
  3. Translating between DTOs and server domain objects.
  4. Calling the appropriate server services to perform game logic.

§Modules

  • dto: Defines Data Transfer Objects for requests and responses.
  • error: Defines ApiError and other API-level errors.
  • services: Implements the core business logic for API endpoints.

§Server Integration

When compiled with the server feature, the crate exposes:

  • ServerStateExtractor: a wrapper around server::ServerState for use by the API.
  • initialize_server_state: function to initialize the shared server state.

Modules§

action
Actions that modify the game state.
dto
Data Transfer Object (DTO) definitions used by the services layer.
error
Error types used throughout the services module.
queries
Queries that retrieve game or user data.
stream
Streaming endpoints for real-time updates.

Structs§

ServerStateExtractor
Alias for ExtractedServerState used in HTTP request handlers to extract the current server state. A wrapper around ServerState used for extracting the state in contexts such as HTTP request handlers or middleware.

Functions§

initialize_server_state
Constructs the shared ServerState.