pub struct FoundryLocalManager { /* private fields */ }Expand description
Primary entry point for interacting with Foundry Local.
Obtain a handle with FoundryLocalManager::create. While at least one
handle is alive, every caller shares the same instance.
Implementations§
Source§impl FoundryLocalManager
impl FoundryLocalManager
Sourcepub fn create(
config: FoundryLocalConfig,
) -> Result<Arc<Self>, FoundryLocalError>
pub fn create( config: FoundryLocalConfig, ) -> Result<Arc<Self>, FoundryLocalError>
Initialise the SDK and return a shared handle to the manager.
While at least one handle is alive — this Arc, or any
Model, client, or session derived from it, each of
which keeps the native manager alive — every call returns a handle to the
same native manager and the config passed to later calls is ignored.
If the Arc returned here is dropped while a derived handle is still
alive, a subsequent call rebuilds a lightweight wrapper around the
still-live native manager rather than creating a second one (the core
permits only one). Once every handle is gone, the next call performs a
fresh initialisation from the new config.
Teardown runs via Drop when the final handle is released — not via a
process-exit hook — so the native manager (and its EP unregistration)
shuts down while the engine / ORT runtime is still alive. This matches
the C++ SDK’s local-Manager semantics and avoids the WebGPU
ReleaseEpFactory teardown throw (ORT #29206).
Sourcepub fn shutdown(&self) -> Result<(), FoundryLocalError>
pub fn shutdown(&self) -> Result<(), FoundryLocalError>
Begin a graceful shutdown of the local engine.
Stops the web service, prevents new model loads, stops existing sessions, and unloads models. Idempotent and safe to call from any thread.
Calling this is optional: the native manager is released automatically
when the last handle is dropped. Use it when you want to deterministically
wind the engine down before releasing the handle. After calling
shutdown, the manager should not be used for further inference.
Sourcepub fn urls(&self) -> Result<Vec<String>, FoundryLocalError>
pub fn urls(&self) -> Result<Vec<String>, FoundryLocalError>
URLs that the local web service is listening on.
Empty until Self::start_web_service has been called.
Sourcepub async fn start_web_service(&self) -> Result<(), FoundryLocalError>
pub async fn start_web_service(&self) -> Result<(), FoundryLocalError>
Start the local web service.
The listening URLs are stored internally and can be retrieved via
Self::urls after this method returns.
Sourcepub async fn stop_web_service(&self) -> Result<(), FoundryLocalError>
pub async fn stop_web_service(&self) -> Result<(), FoundryLocalError>
Stop the local web service.
Sourcepub fn discover_eps(&self) -> Result<Vec<EpInfo>, FoundryLocalError>
pub fn discover_eps(&self) -> Result<Vec<EpInfo>, FoundryLocalError>
Discover available execution providers and their registration status.
Sourcepub async fn download_and_register_eps(
&self,
names: Option<&[&str]>,
) -> Result<EpDownloadResult, FoundryLocalError>
pub async fn download_and_register_eps( &self, names: Option<&[&str]>, ) -> Result<EpDownloadResult, FoundryLocalError>
Download and register execution providers.
If names is None or empty, all available EPs are downloaded.
Otherwise only the named EPs are downloaded and registered.
Sourcepub async fn download_and_register_eps_with_progress<F>(
&self,
names: Option<&[&str]>,
progress_callback: F,
) -> Result<EpDownloadResult, FoundryLocalError>
pub async fn download_and_register_eps_with_progress<F>( &self, names: Option<&[&str]>, progress_callback: F, ) -> Result<EpDownloadResult, FoundryLocalError>
Download and register execution providers, reporting per-EP progress.
If names is None or empty, all available EPs are downloaded.
Otherwise only the named EPs are downloaded and registered.
progress_callback receives (ep_name, percent) where percent
ranges from 0.0 to 100.0 as each EP downloads.
Sourcepub fn download_and_register_eps_builder(&self) -> EpDownloadBuilder<'_>
pub fn download_and_register_eps_builder(&self) -> EpDownloadBuilder<'_>
Configure and run execution provider downloads with a builder.
Use this for call sites that need names, progress, cancellation, or future download options.