pub struct Cache<E, T>{ /* 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>
impl<E, T> Cache<E, T>
Sourcepub fn new(function: fn(Lists<T, E>) -> bool) -> Self
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
}
Sourcepub fn call(&mut self) -> bool
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
}
Sourcepub fn insert(&mut self, link: T, value: E)
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
}
Sourcepub fn get(&self, link: T) -> Option<E>
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
}
Sourcepub fn save(&self)
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>where
T: RefUnwindSafe,
E: RefUnwindSafe,
impl<E, T> Send for Cache<E, T>
impl<E, T> Sync for Cache<E, T>
impl<E, T> Unpin for Cache<E, T>
impl<E, T> UnwindSafe for Cache<E, T>where
T: UnwindSafe,
E: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more