//! The SpacetimeDB Rust client SDK, which enables native Rust applications
//! to communicate with SpacetimeDB modules.
//!
//! This library depends on a set of module-specific definitions
//! autogenerated by [the SpacetimeDB CLI](https://spacetimedb.com/install).
//! See [the SpacetimeDB Rust client SDK reference](https://spacetimedb.com/docs/sdks/rust#generate-module-bindings)
//! for more oh how to generate these bindings.

// Any `#[doc(hidden)]` modules or uses are public because
// code generated by the CLI's codegen references them,
// but users should not.

mod callbacks;
mod client_cache;
mod compression;
mod db_connection;
mod metrics;
mod spacetime_module;
mod subscription;
mod websocket;

pub mod credentials;
pub mod db_context;
pub mod error;
pub mod event;
pub mod table;

pub use db_connection::DbConnectionBuilder;
pub use db_context::DbContext;
pub use error::{Error, Result};
pub use event::{Event, ReducerEvent, Status};
pub use table::{Table, TableWithPrimaryKey};

pub use spacetime_module::SubscriptionHandle;
pub use spacetimedb_client_api_messages::websocket::Compression;
pub use spacetimedb_lib::{ConnectionId, Identity, ScheduleAt, TimeDuration, Timestamp};
pub use spacetimedb_sats::{i256, u256};

#[doc(hidden)]
pub mod __codegen {
    //! Names and definitions referenced by the CLI's codegen.
    //!
    //! Necessarily public, but should not be considered part of this library's public interface.
    //! These may change incompatibly without a major version bump.
    pub use http;
    pub use log;
    pub use spacetimedb_client_api_messages::websocket as __ws;
    pub use spacetimedb_lib as __lib;
    pub use spacetimedb_sats as __sats;

    pub use crate::callbacks::{CallbackId, DbCallbacks};
    pub use crate::client_cache::{ClientCache, TableAppliedDiff, TableHandle, UniqueConstraintHandle};
    pub use crate::db_connection::DbContextImpl;
    pub use crate::error::{Error, InternalError, Result};
    pub use crate::spacetime_module::{
        parse_reducer_args, AbstractEventContext, AppliedDiff, DbConnection, DbUpdate, ErrorContext, EventContext,
        InModule, ProcedureEventContext, Reducer, ReducerEventContext, SpacetimeModule, SubscriptionEventContext,
        SubscriptionHandle, TableUpdate,
    };
    pub use crate::subscription::{OnEndedCallback, SubscriptionBuilder, SubscriptionHandleImpl};
    pub use crate::{
        ConnectionId, DbConnectionBuilder, DbContext, Event, Identity, ReducerEvent, ScheduleAt, Table,
        TableWithPrimaryKey, TimeDuration, Timestamp,
    };
}

#[doc(hidden)]
pub mod unstable {
    //! Unstable interfaces not ready for the prime time.
    //!
    //! These may change incompatibly without a major version bump.
    pub use crate::db_connection::set_connection_id;
    pub use crate::metrics::{ClientMetrics, CLIENT_METRICS};
    pub use spacetimedb_client_api_messages::websocket::CallReducerFlags;
}
