Skip to main content

LocalSource

Struct LocalSource 

Source
pub struct LocalSource { /* private fields */ }
Expand description

A voxora_traits::ModelSource that resolves model ids against a directory already on disk.

Constructed via LocalSource::new:

use voxora_local::LocalSource;
use voxora_traits::ModelSource;

let source = LocalSource::new("/srv/models");
let dir = source.resolve("org/repo/model.bin", &Default::default()).await?;
println!("model at {}", dir.entry.expect("entry").display());

resolve joins root_dir with model_id (using PathBuf::join, which already normalises trailing slashes), checks the resulting path with std::path::Path::is_file (which follows symlinks on Unix), and returns a voxora_traits::ModelDir with entry set to the absolute-or-relative file path matching the input root’s absoluteness. If the file is missing, the error is voxora_traits::AsrError::ModelNotFound naming both the missing path and the configured root.

The implementation never touches the network and never reads outside root_dir + model_id. Callers wanting a richer capabilities answer than ModelCapabilities::UNKNOWN should do it themselves — see voxora-hf for an example of synthesising capabilities from a filename pattern.

Implementations§

Source§

impl LocalSource

Source

pub fn new(root: impl Into<PathBuf>) -> Self

Build a source that resolves model ids against root.

The root is stored verbatim — no canonicalize, no existence check. An empty directory listing at resolve time surfaces as AsrError::ModelNotFound, not as a constructor failure. Trailing slashes are folded by PathBuf::join, so new("/srv/models/") and new("/srv/models") behave identically.

Absolute and relative roots are both supported; the entry field on the returned ModelDir inherits the same prefix (absolute root → absolute entry, relative root → relative entry). Most callers want an absolute root.

Source

pub fn root(&self) -> &Path

Borrow the configured root directory.

Trait Implementations§

Source§

impl Clone for LocalSource

Source§

fn clone(&self) -> LocalSource

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for LocalSource

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl ModelSource for LocalSource

Source§

fn name(&self) -> &'static str

Short, stable identifier for this source ("huggingface", "local", …).
Source§

fn resolve<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, model_id: &'life1 str, _opts: &'life2 ResolveOptions, ) -> Pin<Box<dyn Future<Output = Result<ModelDir, AsrError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Resolve a model id (e.g. Qwen/Qwen3-ASR-0.6B) to a concrete ModelDir on disk, downloading if necessary.
Source§

fn capabilities_for<'life0, 'life1, 'async_trait>( &'life0 self, _model_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<ModelCapabilities, AsrError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Query a model’s capabilities without downloading the weights.
Source§

fn list_available<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<ModelDescriptor>, AsrError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

List models known to this source. Defaults to AsrError::Unsupported because not every source can enumerate.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.