[][src]Struct db::clients::ClientHandler

pub struct ClientHandler;

Holds utilities to maniuplate the Client table in the database

Methods

impl ClientHandler[src]

pub fn upsert(
    &self,
    conn: &PgConnection,
    new_client: &Client
) -> QueryResult<Client>
[src]

Attempts to insert a new client with UID, if there is a conflic, it will update the record.

pub fn upsert_batch(
    &self,
    conn: &PgConnection,
    clients: ClientVector
) -> QueryResult<()>
[src]

Attempts to insert a new client with UID, if there is a conflic, it will update the record. Doesn't work quite as expected.. Followed the guides from here but doesn't seem to actually set the excluded value where the conflict happened..

pub fn remove_uid(&self, conn: &PgConnection, id: UID) -> QueryResult<usize>[src]

Permanently remove record from table, by UID

pub fn remove_uids(
    &self,
    conn: &PgConnection,
    uids: Vec<UID>
) -> QueryResult<usize>
[src]

Remove a list of UIDS from db by suppling a vec of UIDs careful if supplied vector is empty, it will remove all records in table

pub fn uid_exists(&self, conn: &PgConnection, id: UID) -> bool[src]

checks to see if UID of client exists within database

pub fn get_uid(&self, conn: &PgConnection, id: UID) -> QueryResult<ClientVector>[src]

Get single UID from db, if UID doesn't exist it will return an empty vector

pub fn get_uids(
    &self,
    conn: &PgConnection,
    uids: Vec<UID>
) -> QueryResult<ClientVector>
[src]

Retrieve a list of UIDS from db by suppling a vec of UIDs if an empty set of uids is supplied, it will retrieve all records in table

pub fn get_uids_range(
    &self,
    conn: &PgConnection,
    from: UID,
    to: UID
) -> QueryResult<ClientVector>
[src]

Get a range of UIDs Note that UIDS that do not exists will be logged, but will not show up in the returned vector

pub fn get_ip_exact<'a>(
    &self,
    conn: &PgConnection,
    ip: &'a str
) -> QueryResult<ClientVector>
[src]

retrieve records with exact IP address

pub fn get_ip_like<'a>(
    &self,
    conn: &PgConnection,
    pattern_match: String
) -> QueryResult<ClientVector>
[src]

retrieve a vector of ip address with the appropriate match pattern provided

This example is not tested
let pattern = format!("%{}%", "168.0");

// vector of Clients objects with ips matching `*168.0*`
let results = ClientHandler::get_ip_like(&conn, pattern);

Auto Trait Implementations

impl RefUnwindSafe for ClientHandler

impl Send for ClientHandler

impl Sync for ClientHandler

impl Unpin for ClientHandler

impl UnwindSafe for ClientHandler

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> IntoSql for T

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,