pub struct Storage { /* private fields */ }Expand description
Synchronous, file-backed cache.
Implementations§
Source§impl Storage
impl Storage
Sourcepub fn new() -> Result<Self>
pub fn new() -> Result<Self>
Create a Storage resolving the cache dir exactly like the JS:
honor ~/.tse tracker file if present, else default to ~/tse-cache.
Sourcepub fn with_dir<P: AsRef<Path>>(dir: P) -> Result<Self>
pub fn with_dir<P: AsRef<Path>>(dir: P) -> Result<Self>
Create a Storage rooted at an explicit directory (useful for tests).
Sourcepub fn get_item(&self, key: &str) -> Result<String>
pub fn get_item(&self, key: &str) -> Result<String>
Read a value, creating an empty file if missing (JS getItem).
Sourcepub fn get_item_async(&self, key: &str, zip: bool) -> Result<String>
pub fn get_item_async(&self, key: &str, zip: bool) -> Result<String>
Async-equivalent read (JS getItemAsync). Optionally gunzips.
Sourcepub fn set_item_async(&self, key: &str, value: &str, zip: bool) -> Result<()>
pub fn set_item_async(&self, key: &str, value: &str, zip: bool) -> Result<()>
Async-equivalent write (JS setItemAsync). Optionally gzips.
Sourcepub fn get_items(
&self,
selins: &HashSet<String>,
result: &mut HashMap<String, String>,
) -> Result<()>
pub fn get_items( &self, selins: &HashSet<String>, result: &mut HashMap<String, String>, ) -> Result<()>
Load the cached price CSVs for the selected instruments (JS getItems).
Only the requested inscodes are read into result.
Sourcepub fn itd_get_items(
&self,
selins: &HashSet<String>,
full: bool,
) -> Result<HashMap<String, HashMap<String, ItdValue>>>
pub fn itd_get_items( &self, selins: &HashSet<String>, full: bool, ) -> Result<HashMap<String, HashMap<String, ItdValue>>>
Intraday: read stored devens for selected instruments (JS itd.getItems).
When full is true, the gzipped bytes are returned; otherwise each
deven maps to an empty marker (presence only).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Storage
impl RefUnwindSafe for Storage
impl Send for Storage
impl Sync for Storage
impl Unpin for Storage
impl UnsafeUnpin for Storage
impl UnwindSafe for Storage
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