Struct move_cli::sandbox::utils::on_disk_state_view::OnDiskStateView
source · pub struct OnDiskStateView { /* private fields */ }
Implementations§
source§impl OnDiskStateView
impl OnDiskStateView
sourcepub fn create<P: Into<PathBuf>>(build_dir: P, storage_dir: P) -> Result<Self>
pub fn create<P: Into<PathBuf>>(build_dir: P, storage_dir: P) -> Result<Self>
Create an OnDiskStateView
that reads/writes resource data and modules in storage_dir
.
pub fn interface_files_dir(&self) -> Result<String>
pub fn build_dir(&self) -> &PathBuf
pub fn struct_layouts_dir(&self) -> PathBuf
pub fn is_resource_path(&self, p: &Path) -> bool
pub fn is_event_path(&self, p: &Path) -> bool
pub fn is_module_path(&self, p: &Path) -> bool
sourcepub fn get_module_id(&self, p: &Path) -> Option<ModuleId>
pub fn get_module_id(&self, p: &Path) -> Option<ModuleId>
Extract a module ID from a path
sourcepub fn get_resource_bytes(
&self,
addr: AccountAddress,
tag: StructTag
) -> Result<Option<Vec<u8>>>
pub fn get_resource_bytes( &self, addr: AccountAddress, tag: StructTag ) -> Result<Option<Vec<u8>>>
Read the resource bytes stored on-disk at addr
/tag
sourcepub fn has_module(&self, module_id: &ModuleId) -> bool
pub fn has_module(&self, module_id: &ModuleId) -> bool
Check if a module at addr
/module_id
exists
sourcepub fn resolve_function(
&self,
module_id: &ModuleId,
idx: u16
) -> Result<Option<Identifier>>
pub fn resolve_function( &self, module_id: &ModuleId, idx: u16 ) -> Result<Option<Identifier>>
Return the name of the function at idx
in module_id
sourcepub fn view_resource(
&self,
resource_path: &Path
) -> Result<Option<AnnotatedMoveStruct>>
pub fn view_resource( &self, resource_path: &Path ) -> Result<Option<AnnotatedMoveStruct>>
Returns a deserialized representation of the resource value stored at resource_path
.
Returns Err if the path does not hold a resource value or the resource cannot be deserialized
pub fn view_events(&self, events_path: &Path) -> Result<Vec<AnnotatedMoveValue>>
pub fn view_module(module_path: &Path) -> Result<Option<String>>
pub fn view_script(script_path: &Path) -> Result<Option<String>>
sourcepub fn delete_resource(&self, addr: AccountAddress, tag: StructTag) -> Result<()>
pub fn delete_resource(&self, addr: AccountAddress, tag: StructTag) -> Result<()>
Delete resource stored on disk at the path addr
/tag
pub fn save_resource( &self, addr: AccountAddress, tag: StructTag, bcs_bytes: &[u8] ) -> Result<()>
pub fn save_event( &self, event_key: &[u8], event_sequence_number: u64, event_type: TypeTag, event_data: Vec<u8> ) -> Result<()>
sourcepub fn save_module(&self, module_id: &ModuleId, module_bytes: &[u8]) -> Result<()>
pub fn save_module(&self, module_id: &ModuleId, module_bytes: &[u8]) -> Result<()>
Save module
on disk under the path module.address()
/module.name()
sourcepub fn save_layout_yaml(
&self,
id: StructTag,
layout: &MoveStructLayout
) -> Result<()>
pub fn save_layout_yaml( &self, id: StructTag, layout: &MoveStructLayout ) -> Result<()>
Save the YAML encoding layout
on disk under build_dir/layouts/id
.
sourcepub fn save_modules<'a>(
&self,
modules: impl IntoIterator<Item = &'a (ModuleIdWithNamedAddress, Vec<u8>)>,
named_address_values: BTreeMap<String, AddressBytes>
) -> Result<()>
pub fn save_modules<'a>( &self, modules: impl IntoIterator<Item = &'a (ModuleIdWithNamedAddress, Vec<u8>)>, named_address_values: BTreeMap<String, AddressBytes> ) -> Result<()>
Save all the modules in the local cache, re-generate mv_interfaces if required.
pub fn delete_module(&self, id: &ModuleId) -> Result<()>
pub fn resource_paths(&self) -> impl Iterator<Item = PathBuf> + '_
pub fn module_paths(&self) -> impl Iterator<Item = PathBuf> + '_
pub fn event_paths(&self) -> impl Iterator<Item = PathBuf> + '_
sourcepub fn get_all_modules(&self) -> Result<Vec<CompiledModule>>
pub fn get_all_modules(&self) -> Result<Vec<CompiledModule>>
Build all modules in the self.storage_dir. Returns an Err if a module does not deserialize.