Files
client/crates/forage-server/src/state.rs
2026-03-08 23:00:03 +01:00

39 lines
1009 B
Rust

use std::sync::Arc;
use crate::forest_client::GrpcForestClient;
use crate::templates::TemplateEngine;
use forage_core::auth::ForestAuth;
use forage_core::platform::ForestPlatform;
use forage_core::session::SessionStore;
#[derive(Clone)]
pub struct AppState {
pub templates: TemplateEngine,
pub forest_client: Arc<dyn ForestAuth>,
pub platform_client: Arc<dyn ForestPlatform>,
pub sessions: Arc<dyn SessionStore>,
pub grpc_client: Option<Arc<GrpcForestClient>>,
}
impl AppState {
pub fn new(
templates: TemplateEngine,
forest_client: Arc<dyn ForestAuth>,
platform_client: Arc<dyn ForestPlatform>,
sessions: Arc<dyn SessionStore>,
) -> Self {
Self {
templates,
forest_client,
platform_client,
sessions,
grpc_client: None,
}
}
pub fn with_grpc_client(mut self, client: Arc<GrpcForestClient>) -> Self {
self.grpc_client = Some(client);
self
}
}