SearchChannel

Struct SearchChannel 

Source
pub struct SearchChannel(/* private fields */);
Expand description

The Sonic Channel Search mode is used for querying the search index. Once in this mode, you cannot switch to other modes or gain access to commands from other modes.

§Available commands

In this mode you can use query, suggest, ping and quit commands.

Note: This mode requires enabling the search feature.

Implementations§

Source§

impl SearchChannel

Source

pub fn quit(&self) -> Result<<QuitCommand as StreamCommand>::Response>

Stop connection.

let channel = SearchChannel::start(
    "localhost:1491",
    "SecretPassword",
)?;

channel.quit()?;
Source

pub fn ping(&self) -> Result<<PingCommand as StreamCommand>::Response>

Ping server.

let channel = SearchChannel::start(
    "localhost:1491",
    "SecretPassword",
)?;

channel.ping()?;
Source§

impl SearchChannel

Source

pub fn query( &self, req: QueryRequest, ) -> Result<<QueryCommand as StreamCommand>::Response>

Query objects in database.

Note: This method requires enabling the search feature and start connection in Search mode.

let search_channel = SearchChannel::start(
    "localhost:1491",
    "SecretPassword",
)?;

let result = search_channel.query(QueryRequest::new(
    Dest::col("search"),
    "Beef",
))?;
dbg!(result);

let result = search_channel.query(
    QueryRequest::new(Dest::col("search"), "Beef").limit(10)
)?;
dbg!(result);
Source

pub fn suggest( &self, req: SuggestRequest, ) -> Result<<SuggestCommand as StreamCommand>::Response>

Suggest auto-completes words.

Note: This method requires enabling the search feature and start connection in Search mode.

let search_channel = SearchChannel::start(
    "localhost:1491",
    "SecretPassword",
)?;

let result = search_channel.suggest(
    SuggestRequest::new(Dest::col("search"), "Beef")
)?;
dbg!(result);

let result = search_channel.suggest(
    SuggestRequest::new(Dest::col("search"), "Beef").limit(2)
)?;
dbg!(result);
Source

pub fn list( &self, req: ListRequest, ) -> Result<<ListCommand as StreamCommand>::Response>

Enumerates all words in an index.

Note: This method requires enabling the search feature and start connection in Search mode.

let search_channel = SearchChannel::start(
    "localhost:1491",
    "SecretPassword",
)?;

let result = search_channel.list(
    ListRequest::new(Dest::col("search"))
)?;
dbg!(result);

let result = search_channel.list(
    ListRequest::new(Dest::col("search")).limit(2)
)?;
dbg!(result);

Trait Implementations§

Source§

impl Debug for SearchChannel

Source§

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

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

impl SonicChannel for SearchChannel

Source§

type Channel = SearchChannel

Sonic channel struct
Source§

fn stream(&self) -> &SonicStream

Returns reference for sonic stream of connection
Source§

fn start<A, S>(addr: A, password: S) -> Result<Self::Channel>
where A: ToSocketAddrs, S: ToString,

Connects to sonic backend and run start command. Read more

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.