state

Shared application state handed to every axum handler.

struct AppState

source

pub struct AppState

Shared 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::author_id

source

pub fn author_id(&self) -> &Option<Id>

The author recorded on notes added through the dashboard, resolved from git at startup.

Parameter Type Description
returns &Option<Id>

AppState::avatar_cache

source

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

source

pub fn project_id(&self) -> &Id

The project whose entities the dashboard shows.

Parameter Type Description
returns &Id

AppState::reload_tx

source

pub fn reload_tx(&self) -> &Sender<()>

The broadcast channel that wakes /events subscribers so browser tabs reload.

Parameter Type Description
returns &Sender<()>

AppState::store

source

pub fn store(&self) -> &Arc<Db>

The database the handlers read and write.

Parameter Type Description
returns &Arc<Db>

AppState::new

source

pub fn new(store: Arc<Db>, project_id: Id) -> Self

Create 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_author_id

source

pub fn with_author_id(self, id: Id) -> Self

Set the resolved author ID.

Parameter Type Description
id Id the author recorded on notes added through the dashboard
returns Self The state with the author set.

AppState::with_avatar_cache

source

pub fn with_avatar_cache(self, cache: Arc<AvatarCache>) -> Self

Set 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.