IngestChannel

Struct IngestChannel 

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

The Sonic Channel Ingest mode is used for altering the search index (push, pop and flush). 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 push, pop, flushc, flushb, flusho, bucket_count, object_count, word_count, ping and quit commands.

Note: This mode requires enabling the ingest feature.

Implementations§

Source§

impl IngestChannel

Source

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

Stop connection.

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

channel.quit()?;
Source

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

Ping server.

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

channel.ping()?;
Source§

impl IngestChannel

Source

pub fn push<'a>( &self, req: PushRequest, ) -> Result<<PushCommand as StreamCommand>::Response>

Push search data in the index.

Note: This method requires enabling the ingest feature and start connection in Ingest mode.

let ingest_channel = IngestChannel::start(
    "localhost:1491",
    "SecretPassword",
)?;

let result = ingest_channel.push(PushRequest::new(
    Dest::col("search").obj("recipe:295"),
    "Sweet Teriyaki Beef Skewers"
))?;
assert_eq!(result, ());
Source

pub fn pop( &self, req: PopRequest, ) -> Result<<PopCommand as StreamCommand>::Response>

Pop search data from the index. Returns removed words count as usize type.

Note: This method requires enabling the ingest feature and start connection in Ingest mode.

let ingest_channel = IngestChannel::start(
    "localhost:1491",
    "SecretPassword",
)?;

let dest = Dest::col("search").obj("recipe:295");
let result = ingest_channel.pop(PopRequest::new(dest, "beef"))?;
assert_eq!(result, 1);
Source

pub fn flush( &self, req: FlushRequest, ) -> Result<<FlushCommand as StreamCommand>::Response>

Flush all indexed data from collections.

Note: This method requires enabling the ingest feature and start connection in Ingest mode.

let ingest_channel = IngestChannel::start(
    "localhost:1491",
    "SecretPassword",
)?;

let flushc_count = ingest_channel.flush(FlushRequest::collection("search"))?;
dbg!(flushc_count);
let flushb_count = ingest_channel.flush(FlushRequest::bucket("search", "default"))?;
dbg!(flushb_count);
let flusho_count = ingest_channel.flush(
    FlushRequest::object("search", "default", "recipe:295")
)?;
dbg!(flusho_count);
Source

pub fn count( &self, req: CountRequest, ) -> Result<<CountCommand as StreamCommand>::Response>

Count indexed search data of your collection.

Note: This method requires enabling the ingest feature and start connection in Ingest mode.

let ingest_channel = IngestChannel::start(
    "localhost:1491",
    "SecretPassword",
)?;

let bucket_count = ingest_channel.count(CountRequest::buckets("search"))?;
dbg!(bucket_count);
let object_count = ingest_channel.count(CountRequest::objects("search", "default"))?;
dbg!(object_count);
let word_count = ingest_channel.count(
    CountRequest::words("search", "default", "recipe:256")
)?;
dbg!(object_count);

Trait Implementations§

Source§

impl Debug for IngestChannel

Source§

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

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

impl SonicChannel for IngestChannel

Source§

type Channel = IngestChannel

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.