Add state module docs

This commit is contained in:
2025-08-10 22:03:58 -03:00
parent b785eaa6c6
commit 0ffb62a7dc
2 changed files with 21 additions and 1 deletions
+1 -1
View File
@@ -26,7 +26,7 @@
//! //!
//! # Parsing Arguments //! # Parsing Arguments
//! //!
//! The arguments are parsed using the [`Args::parse`] method, which returns an instance of the //! The arguments are parsed using the `Args::parse()` method, which returns an instance of the
//! [`Args`] struct. This struct contains the parsed values of the command line arguments, and //! [`Args`] struct. This struct contains the parsed values of the command line arguments, and
//! can be used to initialize the bot and start the event loop. //! can be used to initialize the bot and start the event loop.
//! //!
+20
View File
@@ -1,3 +1,23 @@
//! Application state at runtime, including the database connection and other shared resources.
//!
//! Currently, it only contains the database connection, but it can be extended in the future to
//! include other resources that need to be shared across the application, such as caches or
//! configuration settings.
//!
//! It is shared around the application using an `Arc`, allowing it to be cloned and passed around
//! without needing to worry about ownership or lifetimes. This is particularly useful in an
//! asynchronous context.
//!
//! ```
//! let state = State {
//! db: database::init("127.0.0.1:9042").await?,
//! };
//!
//! fn handler_which_needs_state(state: Arc<State>) {
//! // Use the state here
//! }
//! ```
use scylla::client::session::Session; use scylla::client::session::Session;
pub struct State { pub struct State {