Skip to main content

mobius_gateway/
lib.rs

1//! Authenticated, frontend-neutral access to independent möbius chats.
2
3mod assembly;
4pub mod auth;
5pub mod bots;
6mod channel;
7pub mod client;
8mod cloudflare;
9pub mod command;
10pub mod computer_runtime;
11pub mod config;
12mod extensions;
13/// Shared saved gateway accounts and endpoint selection.
14pub mod gateway_accounts;
15mod git;
16mod host;
17mod hostnames;
18mod middleware_manifest;
19mod persistent_chat;
20mod process_environment;
21mod provider_catalog;
22mod publication;
23pub mod sandbox;
24pub mod server;
25pub mod storage_usage;
26pub mod telemetry;
27pub mod wire;
28
29pub use extensions::MAX_EXTENSION_SOURCE_BYTES;
30
31/// Errors returned by the gateway library.
32#[derive(Debug, thiserror::Error)]
33pub enum Error {
34    #[error("gateway configuration error: {0}")]
35    /// Selects the config case.
36    Config(String),
37    #[error("gateway protocol error: {0}")]
38    /// Selects the protocol case.
39    Protocol(String),
40    #[error("gateway protocol error: WebSocket handshake failed: HTTP {status}")]
41    /// A rejected WebSocket upgrade, retaining only safe HTTP retry metadata.
42    WebSocketUpgrade {
43        /// HTTP status returned by the gateway service.
44        status: u16,
45        /// A single positive delta-seconds Retry-After value, when valid.
46        retry_after: Option<std::time::Duration>,
47    },
48    #[error("gateway authentication failed")]
49    /// Selects the unauthorized case.
50    Unauthorized,
51    #[error(transparent)]
52    /// Selects the mobius case.
53    Mobius(#[from] mobius::Error),
54    #[error(transparent)]
55    /// Selects the I/O case.
56    Io(#[from] std::io::Error),
57    #[error(transparent)]
58    /// Selects the JSON case.
59    Json(#[from] serde_json::Error),
60    #[error("Bot storage error")]
61    /// Selects the SQLite case.
62    Sqlite(#[from] rusqlite::Error),
63}
64
65/// Result type shared by gateway modules.
66pub type Result<T> = std::result::Result<T, Error>;