webdav_server/lib.rs
1/// Kosh — a zero-knowledge self-hosted storage server.
2///
3/// This crate is the main library for the Kosh server. It is structured as a
4/// library so that integration tests can import and construct the full application
5/// without duplicating any setup code.
6///
7/// ## Module overview
8///
9/// - [`api`] — HTTP route handlers, middleware, and API-layer error types.
10/// - [`app`] — Application state and the builder used to construct it.
11/// - [`error`] — The top-level error type and its domain-specific sub-modules.
12/// - [`logger`] — Structured asynchronous telemetry: MPSC channel, background service,
13/// daily rolling log files, Unix Datagram Socket broadcasting, and the logging macros.
14/// - [`mod@log`] — A lightweight, deprecated debug-only logging macro and ANSI color helpers.
15/// Superseded by the structured macros in [`logger`].
16/// - [`model`] — Database entity definitions and query functions (users, sessions, assets).
17/// - [`storage`] — The CAS storage engine, file transactions, and blob management.
18///
19/// ## Architecture
20///
21/// ```text
22/// HTTP Request
23/// ↓
24/// log_middleware (post-response — collects error telemetry from extensions)
25/// ↓
26/// auth_guard middleware (Moka cache → SQLite fallback)
27/// ↓
28/// Route Handler (api layer)
29/// ↓
30/// Model Layer (sqlx queries against SQLite)
31/// Storage Layer (streaming to disk, CAS vault)
32/// ↓
33/// crate::Error::into_response() — central error sanitization + telemetry packing
34/// ↓
35/// HTTP Response
36///
37/// Telemetry pipeline (parallel, non-blocking):
38/// crate::Error::into_response()
39/// → inserts Entry into Response::extensions
40/// → log_middleware extracts Entry and calls GLOBAL_LOGGER.try_send(entry)
41/// → Service::run() receives entry, writes bincode to daily .bin file
42/// → broadcasts same bytes to /tmp/kosh-cli.sock (kosh-cli admin dashboard)
43/// ```
44pub mod api;
45pub mod app;
46pub mod log;
47pub mod logger;
48pub mod model;
49pub mod storage;
50
51pub mod error;
52
53pub use error::{Error, Result};
54pub use logger::SOCKET_ADDR;