Struct Cache

Source
pub struct Cache<E, T>
where T: PartialEq + Clone, E: Clone,
{ /* private fields */ }
Expand description

The cache is in form of a Struct with two elements The second part of the cache is the heart of the cache a Costume list type to get the needed performance for my project

Implementations§

Source§

impl<E, T> Cache<E, T>
where T: PartialEq + Clone + Display, E: Clone + Display,

Source

pub fn new(function: fn(Lists<T, E>) -> bool) -> Self

fn new() creates a new cache as an argument it takes an fn(Lists<E, T>) what returns a bool, to check if it had success or failure

§Examples
 use Caching;
 fn main() -> (){
     let cache = caching::Cache::<i32,String>::new(|a/* This is a lists<i32, String>*/|-> bool {return true});
     // Some Code
 }
Source

pub fn call(&mut self) -> bool

calls the expression and parse the Cache cache into it this makes it possible to execute code directly in the cache

§Examples
 use Caching;
 fn main() -> (){
     let cache = caching::Cache::<i32,String>::new(|a/* This is a lists<i32, String>*/|-> bool {return true});
     cache.call(); //This executes the cade in the cache
     // Some Code
 }
Source

pub fn insert(&mut self, link: T, value: E)

insert a linked value into the cache

§Examples
 use Caching;
 fn main() -> (){
     let cache = caching::Cache::<i32,String>::new(|a/* This is a lists<i32, String>*/|-> bool {return true});
     cache.insert(4,"4".to_string()); //This puts the values 4 and "4" in the cache
     // Some Code
 }
Source

pub fn get(&self, link: T) -> Option<E>

insert a linked value into the cache

§Examples
 use Caching;
 fn main() -> (){
     let cache = caching::Cache::<i32,String>::new(|a/* This is a lists<i32, String>*/|-> bool {return true});
     cache.insert(4,"4".to_string()); //This puts the values 4 and "4" in the cache
     cache.get(4); //returns Option enum with None if the value is not the cache and Some(), in this case Some("4")
     // Some Code
 }
Source

pub fn save(&self)

safes the cache into to files

§Examples
 use Caching;
 fn main() -> (){
     let cache = caching::Cache::<i32,String>::new(|a/* This is a lists<i32, String>*/|-> bool {return true});
     cache.insert(4,"4".to_string()); //This puts the values 4 and "4" in the cache
     cahce.save();//This safes the cache in two file, BUT NOT THE FUNCTION  
     // Some Code
 }

Auto Trait Implementations§

§

impl<E, T> Freeze for Cache<E, T>

§

impl<E, T> RefUnwindSafe for Cache<E, T>

§

impl<E, T> Send for Cache<E, T>
where T: Send, E: Send,

§

impl<E, T> Sync for Cache<E, T>
where T: Sync, E: Sync,

§

impl<E, T> Unpin for Cache<E, T>
where T: Unpin, E: Unpin,

§

impl<E, T> UnwindSafe for Cache<E, T>
where T: UnwindSafe, E: UnwindSafe,

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.