Trait fred::types::Scanner

source ·
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§

source

type Page

The type of results from the scan operation.

Required Methods§

source

fn cursor(&self) -> Option<Cow<'_, str>>

Read the cursor returned from the last scan operation.

source

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.

source

fn results(&self) -> &Option<Self::Page>

Return a reference to the last page of results.

source

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.

source

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.

source

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.

Implementors§