Skip to main content

WasmCache

Struct WasmCache 

Source
pub struct WasmCache { /* private fields */ }
Expand description

A local file-system cache for Soroban WASM metadata and binaries.

Implementations§

Source§

impl WasmCache

Source

pub fn new() -> Result<Self, StorageError>

Creates a new WasmCache instance.

The directory location can be overridden via the SDKT_CACHE_DIR environment variable (checked first). If unset or empty, uses the standard OS cache directory:

  • Linux: ~/.cache/soroban-devkit/
  • macOS: ~/Library/Caches/org.SaboLabs.soroban-devkit/
  • Windows: %LOCALAPPDATA%\SaboLabs\soroban-devkit\cache\
Source

pub fn base_dir(&self) -> &Path

Returns the base directory of the cache.

Source

pub fn with_dir<P: AsRef<Path>>(path: P) -> Self

Creates a cache instance targeting a specific directory (useful for testing).

Source

pub fn contains( &self, network: &str, wasm_hash: &str, ) -> Result<bool, StorageError>

Returns true if metadata for the wasm_hash exists in the given network.

Source

pub fn get( &self, network: &str, wasm_hash: &str, ) -> Result<Option<WasmMetadata>, StorageError>

Retrieves parsed metadata from the cache.

§Errors

Returns StorageError::CorruptCache if the JSON is malformed.

Source

pub fn put( &self, network: &str, metadata: &WasmMetadata, wasm_bytes: &[u8], ) -> Result<(), StorageError>

Writes both metadata and raw WASM to the cache using atomic tempfile renaming.

Source

pub fn remove(&self, network: &str, wasm_hash: &str) -> Result<(), StorageError>

Removes a specific WASM entry (both JSON and .wasm) from the cache.

A hash that is not cached is an error, not a silent success: callers print “Removed” on Ok, and reporting success for a no-op reads as a completed mutation to scripts and agents. Matches identity delete and network remove, which surface Not found: and exit non-zero.

Source

pub fn clear(&self, network: &str) -> Result<(), StorageError>

Clears all cached WASM entries for a specific network.

Unlike remove, this stays truthful as a no-op success: “cleared” is accurate for an empty cache (the post-condition holds), and unlike a hash miss it is not evidence that a named target was deleted.

Source

pub fn cache_info(&self, network: &str) -> Result<CacheInfo, StorageError>

Retrieves usage statistics for a specific network. A missing or unreadable cache directory is treated as an empty cache (zero entries / zero size) on every platform. This keeps cache info working on fresh CI runners (Linux/macOS/Windows) where the cache path does not yet exist.

Auto Trait Implementations§

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more