pub fn prepare_state(&self, storage_dir: &Path) -> Result<OnDiskStateView> {
        let state = OnDiskStateView::create(self.build_dir.as_path(), storage_dir)?;

        // preload the storage with library modules (if such modules do not exist yet)
        let package = self.package();
        let new_modules: Vec<_> = package
            .dependencies
            .iter()
            .flat_map(|dep| {
                dep.compiled_modules()
                    .iter_modules_owned()
                    .into_iter()
                    .filter(|m| !state.has_module(&m.self_id()))
            })
            .collect();

        let mut serialized_modules = vec![];
        for module in new_modules {
            let self_id = module.self_id();
            let mut module_bytes = vec![];
            module.serialize(&mut module_bytes)?;
            serialized_modules.push((self_id, module_bytes));
        }
        state.save_modules(&serialized_modules)?;

        Ok(state)
    }
/// Prepare an OnDiskStateView that is ready to use. Library modules will be preloaded into the
/// storage if `load_libraries` is true.
///
/// NOTE: this is the only way to get a state view in Move CLI, and thus, this function needs
/// to be run before every command that needs a state view, i.e., `publish`, `run`,
/// `view`, and `doctor`.
Prepare an OnDiskStateView that is ready to use. Library modules will be preloaded into the
storage if `load_libraries` is true.


Prepare an OnDiskStateView that is ready to use . Library modules will be preloaded into the storage if ` load_libraries ` is true .
pub fn prepare_state(&self, storage_dir: &Path) -> Result<OnDiskStateView> {
        let state = OnDiskStateView::create(self.build_dir.as_path(), storage_dir)?;
        // preload the storage with library modules (if such modules do not exist yet)
        let package = self.package();
        let new_modules: Vec<_> = package
            .dependencies
            .iter()
            .flat_map(|dep| {
                dep.compiled_modules()
                    .iter_modules_owned()
                    .into_iter()
                    .filter(|m| !state.has_module(&m.self_id()))
            })
            .collect();
        let mut serialized_modules = vec![];
        for module in new_modules {
            let self_id = module.self_id();
            let mut module_bytes = vec![];
            module.serialize(&mut module_bytes)?;
            serialized_modules.push((self_id, module_bytes));
        }
        state.save_modules(&serialized_modules)?;
        Ok(state)
    }
pub fn prepare_state ( & self , storage_dir : & Path ) -> Result < OnDiskStateView > { let state = OnDiskStateView :: create ( self . build_dir . as_path ( ) , storage_dir ) ? ; // preload the storage with library modules (if such modules do not exist yet) let package = self . package ( ) ; let new_modules : Vec < _ > = package . dependencies . iter ( ) . flat_map ( | dep | { dep . compiled_modules ( ) . iter_modules_owned ( ) . into_iter ( ) . filter ( | m | ! state . has_module ( & m . self_id ( ) ) ) } ) . collect ( ) ; let mut serialized_modules = vec ! [ ] ; for module in new_modules { let self_id = module . self_id ( ) ; let mut module_bytes = vec ! [ ] ; module . serialize ( & mut module_bytes ) ? ; serialized_modules . push ( ( self_id , module_bytes ) ) ; } state . save_modules ( & serialized_modules ) ? ; Ok ( state ) }
Prepare an OnDiskStateView that is ready to use.
Prepare an OnDiskStateView that is ready to use .
&self
storage_dir
&Path