pub trait Scanner {
type Page;
// Required methods
fn cursor(&self) -> Option<Cow<'_, str>>;
fn has_more(&self) -> bool;
fn results(&self) -> &Option<Self::Page>;
fn take_results(&mut self) -> Option<Self::Page>;
fn create_client(&self) -> RedisClient;
fn next(self) -> Result<(), RedisError>;
}Expand description
An interface for interacting with the results of a scan operation.
Required Associated Types§
Required Methods§
sourcefn cursor(&self) -> Option<Cow<'_, str>>
fn cursor(&self) -> Option<Cow<'_, str>>
Read the cursor returned from the last scan operation.
sourcefn has_more(&self) -> bool
fn has_more(&self) -> bool
Whether the scan call will continue returning results. If false this will be the last result set
returned on the stream.
Calling next when this returns false will return Ok(()), so this does not need to be checked on each
result.
sourcefn take_results(&mut self) -> Option<Self::Page>
fn take_results(&mut self) -> Option<Self::Page>
Take ownership over the results of the SCAN operation. Calls to results or take_results will return None
afterwards.
sourcefn create_client(&self) -> RedisClient
fn create_client(&self) -> RedisClient
A lightweight function to create a Redis client from the SCAN result.
To continue scanning the caller should call next on this struct. Calling scan again on the client will
initiate a new SCAN call starting with a cursor of 0.
sourcefn next(self) -> Result<(), RedisError>
fn next(self) -> Result<(), RedisError>
Move on to the next page of results from the SCAN operation. If no more results are available this may close the stream.
This must be called to continue scanning the keyspace. Results are not automatically scanned in the background since this could cause the buffer backing the stream to grow too large very quickly. This interface provides a mechanism for throttling the throughput of the SCAN call. If this struct is dropped without calling this function the stream will close without an error.
If this function returns an error the scan call cannot continue as the client has been closed, or some other fatal error has occurred. If this happens the error will appear in the stream from the original SCAN call.