pub struct OpfsSAHPoolUtil { /* private fields */ }
Expand description
A OpfsSAHPoolUtil instance is exposed to clients in order to manipulate an OpfsSAHPool object without directly exposing that object and allowing for some semantic changes compared to that class.
Implementations§
Source§impl OpfsSAHPoolUtil
impl OpfsSAHPoolUtil
Sourcepub async fn add_capacity(&self, n: u32) -> Result<u32, OpfsSAHError>
pub async fn add_capacity(&self, n: u32) -> Result<u32, OpfsSAHError>
Adds n entries to the current pool.
Sourcepub async fn reduce_capacity(&self, n: u32) -> Result<u32, OpfsSAHError>
pub async fn reduce_capacity(&self, n: u32) -> Result<u32, OpfsSAHError>
Removes up to n entries from the pool, with the caveat that it can only remove currently-unused entries.
Sourcepub fn get_capacity(&self) -> u32
pub fn get_capacity(&self) -> u32
Returns the number of files currently contained in the SAH pool.
Sourcepub fn get_file_count(&self) -> u32
pub fn get_file_count(&self) -> u32
Returns the number of files from the pool currently allocated to VFS slots.
Sourcepub fn get_file_names(&self) -> Vec<String>
pub fn get_file_names(&self) -> Vec<String>
Returns an array of the names of the files currently allocated to VFS slots.
Sourcepub async fn reserve_minimum_capacity(
&self,
min: u32,
) -> Result<(), OpfsSAHError>
pub async fn reserve_minimum_capacity( &self, min: u32, ) -> Result<(), OpfsSAHError>
Removes up to n entries from the pool, with the caveat that it can only remove currently-unused entries.
Sourcepub fn unlink(&self, name: &str) -> Result<bool, OpfsSAHError>
pub fn unlink(&self, name: &str) -> Result<bool, OpfsSAHError>
If a virtual file exists with the given name, disassociates it from the pool and returns true, else returns false without side effects.
Sourcepub fn export_file(&self, name: &str) -> Result<Vec<u8>, OpfsSAHError>
pub fn export_file(&self, name: &str) -> Result<Vec<u8>, OpfsSAHError>
Synchronously reads the contents of the given file into a Vec
Sourcepub fn import_db(&self, path: &str, bytes: &[u8]) -> Result<(), OpfsSAHError>
pub fn import_db(&self, path: &str, bytes: &[u8]) -> Result<(), OpfsSAHError>
Imports the contents of an SQLite database, provided as a byte array under the given name, overwriting any existing content.
If the database is imported with WAL mode enabled, it will be forced to write back to legacy mode, see https://sqlite.org/forum/forumpost/67882c5b04.
If the imported DB is encrypted, use import_db_unchecked
instead.
Sourcepub fn import_db_unchecked(
&self,
path: &str,
bytes: &[u8],
) -> Result<(), OpfsSAHError>
pub fn import_db_unchecked( &self, path: &str, bytes: &[u8], ) -> Result<(), OpfsSAHError>
Can be used to import encrypted DB
Sourcepub async fn wipe_files(&self) -> Result<(), OpfsSAHError>
pub async fn wipe_files(&self) -> Result<(), OpfsSAHError>
Clears all client-defined state of all SAHs and makes all of them available for re-use by the pool.