[][src]Trait ids_service::common::Uids

pub trait Uids {
    type Id;
    fn get_id(&mut self) -> Self::Id { ... }
fn get_id_from_cache(&mut self) -> Option<Self::Id> { ... } }

Trait with functions to get an id

Associated Types

type Id

Loading content...

Provided methods

fn get_id(&mut self) -> Self::Id

Get an id from cache, if the cache is empty. The function try to create an id on fly.

fn get_id_from_cache(&mut self) -> Option<Self::Id>

Get an id from cache. If cache is empty it return None.

Loading content...

Implementors

impl Uids for ids_service::crypto_hash::IdsService[src]

implement Uids

type Id = Vec<u8>

fn get_id(&mut self) -> Self::Id[src]

Get an id. It may never failed even if cache is empty. If cache is empty it create an id on fly.

Examples

extern crate ids_service;

use crate::ids_service::crypto_hash::*;
use crate::ids_service::common::*;

fn main() {

    let mut ids = IdsService::default();
    ids.start();
    println!("Get an id: {}", ids.get_id().as_hex());
}

fn get_id_from_cache(&mut self) -> Option<Self::Id>[src]

Get an id from the cache. If the cache is empty It return None

Examples

extern crate ids_service;

use crate::ids_service::crypto_hash::*;
use crate::ids_service::common::*;

fn main() {

    let mut ids = IdsService::default();
    ids.start();
    ids.filled_event().recv().is_ok();
    println!("Get an id from cache: {}", ids.get_id_from_cache().expect("Expect an id").as_hex());
}

impl Uids for ids_service::rust_hash::IdsService[src]

Implement trait Uids

type Id = u64

fn get_id(&mut self) -> Self::Id[src]

Get an id. It may never failed even if cache is empty. If cache is empty it create an id on fly.

Examples

extern crate ids_service;

use crate::ids_service::rust_hash::*;
use crate::ids_service::common::*;

fn main() {

    let mut ids = IdsService::default();
    ids.start();
    println!("Get an id: {}", ids.get_id().as_hex());
}

fn get_id_from_cache(&mut self) -> Option<Self::Id>[src]

Get an id from the cache. If the cache is empty It return None

Examples

extern crate ids_service;

use crate::ids_service::rust_hash::*;
use crate::ids_service::common::*;

fn main() {

    let mut ids = IdsService::default();
    ids.start();
    ids.filled_event().recv().is_ok();
    println!("Get an id from cache: {}", ids.get_id_from_cache().expect("Expect an id").as_hex());
}
Loading content...