Trait skytable::types::IntoSkyhashAction[][src]

pub trait IntoSkyhashAction: Send + Sync {
    fn push_into_query(&self, data: &mut Query);
fn incr_len_by(&self) -> usize; }
Expand description

Anything that implements this trait can directly add itself to the bytes part of a Query object

Implementing this trait

This trait does not need to be implemented manually for some basic objects. Once you implement IntoSkyhashBytes, it is implemented automatically. This trait will need to be implemented manually for other objects however. For example:

use skytable::types::IntoSkyhashAction;
use skytable::Query;

struct MyVecWrapper(Vec<String>);

impl IntoSkyhashAction for MyVecWrapper {
    fn push_into_query(&self, q: &mut Query) {
        self.0.iter().for_each(|element| q.push(element));
    }
    fn incr_len_by(&self) -> usize {
        self.0.len()
    }
}

Unexpected behavior

As you can see, it is easy enough for someone to miss an element while implementing (maybe not the best example) IntoSkyhashAction::push_into_query() and also misguide the client driver about the length in the implementation for IntoSkyhashAction::incr_len_by(). This is why you should stay on the guard while implementing it.

Required methods

fn push_into_query(&self, data: &mut Query)[src]

Extend the bytes of a Vec of bytes

fn incr_len_by(&self) -> usize[src]

Returns the number of items Self will add to the query

Implementations on Foreign Types

impl<T> IntoSkyhashAction for Vec<T> where
    T: IntoSkyhashBytes
[src]

fn push_into_query(&self, data: &mut Query)[src]

fn incr_len_by(&self) -> usize[src]

impl<T> IntoSkyhashAction for &Vec<T> where
    T: IntoSkyhashBytes
[src]

fn push_into_query(&self, data: &mut Query)[src]

fn incr_len_by(&self) -> usize[src]

impl<T> IntoSkyhashAction for &[T] where
    T: IntoSkyhashBytes
[src]

fn push_into_query(&self, data: &mut Query)[src]

fn incr_len_by(&self) -> usize[src]

impl<T: IntoSkyhashBytes, const N: usize> IntoSkyhashAction for [T; N][src]

fn push_into_query(&self, data: &mut Query)[src]

fn incr_len_by(&self) -> usize[src]

impl<T: IntoSkyhashBytes, const N: usize> IntoSkyhashAction for &'static [T; N][src]

fn push_into_query(&self, data: &mut Query)[src]

fn incr_len_by(&self) -> usize[src]

Implementors

impl<T> IntoSkyhashAction for T where
    T: IntoSkyhashBytes
[src]

fn push_into_query(&self, q: &mut Query)[src]

fn incr_len_by(&self) -> usize[src]