pub struct OpfsSAHPoolUtil { /* private fields */ }Expand description
SAHPoolVfs management tool.
Implementations§
Source§impl OpfsSAHPoolUtil
impl OpfsSAHPoolUtil
Sourcepub fn get_capacity(&self) -> u32
pub fn get_capacity(&self) -> u32
Returns the number of files currently contained in the SAH pool.
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 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.
Source§impl OpfsSAHPoolUtil
impl OpfsSAHPoolUtil
Sourcepub fn import_db(
&self,
filename: &str,
bytes: &[u8],
) -> Result<(), OpfsSAHError>
pub fn import_db( &self, filename: &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 database is encrypted, use import_db_unchecked instead.
Sourcepub fn import_db_unchecked(
&self,
filename: &str,
bytes: &[u8],
) -> Result<(), OpfsSAHError>
pub fn import_db_unchecked( &self, filename: &str, bytes: &[u8], ) -> Result<(), OpfsSAHError>
import_db without checking, can be used to import encrypted database.
Sourcepub fn delete_db(&self, filename: &str) -> Result<bool, OpfsSAHError>
pub fn delete_db(&self, filename: &str) -> Result<bool, OpfsSAHError>
Delete the specified database, make sure that the database is closed.
Sourcepub async fn clear_all(&self) -> Result<(), OpfsSAHError>
pub async fn clear_all(&self) -> Result<(), OpfsSAHError>
Delete all database, make sure that all database is closed.
Sourcepub fn pause_vfs(&self) -> Result<(), OpfsSAHError>
pub fn pause_vfs(&self) -> Result<(), OpfsSAHError>
“Pauses” this VFS by unregistering it from SQLite and relinquishing all open SAHs, leaving the associated files intact. If this instance is already paused, this is a no-op. Returns a Result.
This method returns an error if SQLite has any opened file handles hosted by this VFS, as the alternative would be to invoke Undefined Behavior by closing file handles out from under the library. Similarly, automatically closing any database handles opened by this VFS would invoke Undefined Behavior in downstream code which is holding those pointers.
If this method returns and error due to open file handles then it has no side effects. If the OPFS API returns an error while closing handles then the VFS is left in an undefined state.
Sourcepub async fn unpause_vfs(&self) -> Result<(), OpfsSAHError>
pub async fn unpause_vfs(&self) -> Result<(), OpfsSAHError>
“Unpauses” this VFS, reacquiring all SAH’s and (if successful) re-registering it with SQLite. This is a no-op if the VFS is not currently paused.
The returned a Result. See acquire_access_handles() for how it behaves if it returns an error due to SAH acquisition failure.
Trait Implementations§
impl Send for OpfsSAHPoolUtil
Because it was previously implemented with Send + Sync by mistake,
it is temporarily retained for compatibility reasons and will be
removed in the next major version update.