pub struct AppState {
pub sessions: Arc<SessionRegistry>,
pub pinned: Option<Arc<PinnedProfile>>,
/* private fields */
}Expand description
Bundle of shared state passed into the VoidCrawlServer. Cheap to
clone (two Arcs).
The BrowserPool is lazy: Chrome is not launched until the first tool
call that needs it. This keeps the MCP initialize handshake fast so the
harness can register tools without timing out on browser startup.
Fields§
§sessions: Arc<SessionRegistry>§pinned: Option<Arc<PinnedProfile>>Implementations§
Source§impl AppState
impl AppState
pub fn new(sessions: Arc<SessionRegistry>) -> Self
Sourcepub fn with_pinned_profile(
sessions: Arc<SessionRegistry>,
pinned: PinnedProfile,
) -> Self
pub fn with_pinned_profile( sessions: Arc<SessionRegistry>, pinned: PinnedProfile, ) -> Self
Construct with a pre-acquired profile that will back the pool.
Sourcepub fn with_pool(pool: Arc<BrowserPool>, sessions: Arc<SessionRegistry>) -> Self
pub fn with_pool(pool: Arc<BrowserPool>, sessions: Arc<SessionRegistry>) -> Self
Construct with a pre-built pool already initialized. Useful for tests
that want to inject a specific BrowserPool instead of letting the
state launch Chrome itself.
Sourcepub async fn pool(&self) -> Result<Arc<BrowserPool>>
pub async fn pool(&self) -> Result<Arc<BrowserPool>>
Get the pool, launching Chrome on first call. Subsequent calls reuse the same pool instance.
When a profile is pinned, the pool is built from the pinned
session — browsers=1 (Chrome’s SingletonLock prevents a second
process on the same user_data_dir), tabs_per_browser still
gives real concurrency. Without a pinned profile, the old
BrowserPool::from_env() path runs unchanged.
Sourcepub fn pool_if_initialized(&self) -> Option<Arc<BrowserPool>>
pub fn pool_if_initialized(&self) -> Option<Arc<BrowserPool>>
Returns the initialized pool, if any. Used on shutdown to close without forcing a launch.