FireflyStream

Struct FireflyStream 

Source
pub struct FireflyStream {
    pub default_ttl: usize,
    /* private fields */
}

Fields§

§default_ttl: usize

The default TTL for new records. If this value is not zero, it will be added to the current timestamp. So this is the TTL from when the new is executed.

Implementations§

Source§

impl FireflyStream

Source

pub async fn connect(address: &str) -> FireflyResult<Self>

Instantiate a new TCP connection with a Firefly server. Fails if the connection cannot be established. The expected buffer size is set to 512.

§Arguments
  • address - The address of the Firefly server. (e.g. “127.0.0.1:46600”)
Source

pub async fn connect_with_max_buffer( address: &str, max_buffer_size: usize, ) -> FireflyResult<Self>

Same as FireflyStream::connect, but with a custom buffer size. The buffer size is the maximum expected response size.

§Arguments
  • address - The address of the Firefly server. (e.g. “127.0.0.1:46600”)
  • max_buffer_size - The maximum expected response size.
Source

pub async fn new(&self, key: &str, value: &str) -> OptResult

Create a new record with the default TTL. The default TTL is 0. (record lasts for ever)

§Arguments
  • key - Your unique key for the record.
  • value - The value of the record.
Source

pub async fn new_with_ttl( &self, key: &str, value: &str, ttl: usize, ) -> OptResult

Same as FireflyStream::new, but with a custom TTL. The TTL is the timestamp since the UNIX epoch.

§Arguments
  • key - Your unique key for the record.
  • value - The value of the record.
  • ttl - The timestamp since the UNIX epoch for the data to expire. (0 = never)
Source

pub async fn get(&self, key: &str) -> FireflyResult<(String, usize)>

Get a record from the Firefly server. If you only need the value or ttl use the specific methods for those purposes. As this returns both values.

§Arguments
  • key - The key of the record.
Source

pub async fn get_value(&self, key: &str) -> StringResult

Same as FireflyStream::get, but only returns the value.

§Arguments
  • key - The key of the record.
Source

pub async fn get_ttl(&self, key: &str) -> FireflyResult<usize>

Same as FireflyStream::get, but only returns the ttl.

§Arguments
  • key - The key of the record.
Source

pub async fn drop(&self, key: &str) -> OptResult

Remove a record from the Firefly server.

§Arguments
  • key - The key of the record.
Source

pub async fn drop_values(&self, value: &str) -> OptResult

Remove ALL records that have a certain value. Using this method is generally discouraged. As it is a heavy operation.

§Arguments
  • value - The valy of ANY record that should be removed.

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.