state
Shared application state handed to every axum handler.
struct AppState
pub struct AppStateShared state for the web server.
| Field | Type | Description |
|---|---|---|
author_id |
Option<Id> | The author recorded on notes added through the dashboard, resolved from git at startup. |
avatar_cache |
Arc<AvatarCache> | The on-disk cache that the /avatars/{hash} handler serves avatars from. |
project_id |
Id | The project whose entities the dashboard shows. |
reload_tx |
Sender<()> | The broadcast channel that wakes /events subscribers so browser tabs reload. |
store |
Arc<Db> | The database the handlers read and write. |
Implements Clone.
AppState::avatar_cache
pub fn avatar_cache(&self) -> &Arc<AvatarCache>The on-disk cache that the /avatars/{hash} handler serves avatars from.
| Parameter | Type | Description |
|---|---|---|
| returns | &Arc<AvatarCache> |
AppState::project_id
pub fn project_id(&self) -> &IdThe project whose entities the dashboard shows.
| Parameter | Type | Description |
|---|---|---|
| returns | &Id |
AppState::reload_tx
pub fn reload_tx(&self) -> &Sender<()>The broadcast channel that wakes /events subscribers so browser tabs reload.
| Parameter | Type | Description |
|---|---|---|
| returns | &Sender<()> |
AppState::store
pub fn store(&self) -> &Arc<Db>The database the handlers read and write.
| Parameter | Type | Description |
|---|---|---|
| returns | &Arc<Db> |
AppState::new
pub fn new(store: Arc<Db>, project_id: Id) -> SelfCreate a new web server state.
The avatar cache defaults to a process-scoped temp directory; production
callers should override it via Self::with_avatar_cache so entries are
persisted under the user’s configured storage.cache_dir.
The state starts with no author and a new reload channel that buffers 16 signals.
| Parameter | Type | Description |
|---|---|---|
store |
Arc<Db> | the database the handlers read and write |
project_id |
Id | the project whose entities the dashboard shows |
| returns | Self | The state, with the avatar cache in gest-avatar-cache under the system temp directory. |
AppState::with_avatar_cache
pub fn with_avatar_cache(self, cache: Arc<AvatarCache>) -> SelfSet the avatar cache used by the /avatars/:hash handler.
| Parameter | Type | Description |
|---|---|---|
cache |
Arc<AvatarCache> | the avatar cache to use instead of the default temp directory one |
| returns | Self | The state with the cache replaced. |