pub struct SearchRegistry {
tokens: HashMap<String, CancellationToken>,
}Expand description
In-memory registry of in-flight prefix searches.
Each search is identified by a request_id string. Registering a search
creates a CancellationToken; cancelling it sets the token’s flag. The
background task polls is_cancelled() between pages and emits a final
empty page before exiting.
OCP: the registry is mode-agnostic — future long-running commands can reuse the same pattern by holding their own token kind.
Fields§
§tokens: HashMap<String, CancellationToken>Implementations§
Source§impl SearchRegistry
impl SearchRegistry
Sourcepub fn register(&mut self, request_id: impl Into<String>) -> CancellationToken
pub fn register(&mut self, request_id: impl Into<String>) -> CancellationToken
Register a new search and return a CancellationToken to pass to the
background task.
If a search with the same request_id already exists, it is
overwritten (the old token is dropped, freeing any lingering Arc).
Sourcepub fn cancel(&mut self, request_id: &str) -> bool
pub fn cancel(&mut self, request_id: &str) -> bool
Cancel the search identified by request_id.
Returns true when the token was found and cancelled; false when
no matching search exists (already completed or never started).
Sourcepub fn is_cancelled(&self, request_id: &str) -> bool
pub fn is_cancelled(&self, request_id: &str) -> bool
Returns true when the search has been cancelled (or never started).
Trait Implementations§
Source§impl Default for SearchRegistry
impl Default for SearchRegistry
Source§fn default() -> SearchRegistry
fn default() -> SearchRegistry
Auto Trait Implementations§
impl Freeze for SearchRegistry
impl RefUnwindSafe for SearchRegistry
impl Send for SearchRegistry
impl Sync for SearchRegistry
impl Unpin for SearchRegistry
impl UnsafeUnpin for SearchRegistry
impl UnwindSafe for SearchRegistry
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<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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