pub struct TokenizerRegistry { /* private fields */ }Expand description
Global tokenizer registry living on AppState.
Implementations§
Source§impl TokenizerRegistry
impl TokenizerRegistry
pub fn new( store: Arc<dyn TokenizerStore>, upstream: Arc<dyn TokenizerClient>, ) -> Self
pub fn set_download_enabled(&self, on: bool)
Sourcepub async fn list(&self) -> Vec<VocabInfo>
pub async fn list(&self) -> Vec<VocabInfo>
Builtins + bundled + persisted vocabs (admin surface; async because it asks the persistence backend).
Sourcepub fn resolve(&self, name: &str) -> Option<Arc<Tokenizer>>
pub fn resolve(&self, name: &str) -> Option<Arc<Tokenizer>>
memory → bundled name → None. Persisted/downloaded vocabs only show
up after a background request_load hydrates
them into memory; a miss here never blocks the request.
Sourcepub fn preheat(&self) -> LoadRequestStatus
pub fn preheat(&self) -> LoadRequestStatus
Fire-and-forget warm-up of the bundled vocab on the blocking pool, so the first count request never pays the parse inline. Call once at boot.
Sourcepub fn request_load(&self, name: &str) -> LoadRequestStatus
pub fn request_load(&self, name: &str) -> LoadRequestStatus
Fire-and-forget load pipeline, deduped per name: hydrate from the
persistence backend; when absent there, downloads are enabled, and the
name is an HF repo path (org/repo), download
hf.co/{name}/resolve/main/tokenizer.json through the shared upstream
client and persist it. Never blocks the calling request.
Auto Trait Implementations§
impl !Freeze for TokenizerRegistry
impl !RefUnwindSafe for TokenizerRegistry
impl !UnwindSafe for TokenizerRegistry
impl Send for TokenizerRegistry
impl Sync for TokenizerRegistry
impl Unpin for TokenizerRegistry
impl UnsafeUnpin for TokenizerRegistry
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more