/// Loads the workflow data or creates a new one.
///
/// Reads the data stored in `p` file.
/// Only file name section of `p` is used as data will be always saved
/// in workflow's default data dir.
/// If the file is missing or corrupt a new (empty) Data instance will be returned.
///
/// # Errors:
/// This method can fail if any disk/IO error happens.
Loads the workflow data or creates a new one.
Reads the data stored in `p` file.
Only file name section of `p` is used as data will be always saved
in workflow's default data dir.
If the file is missing or corrupt a new (empty) Data instance will be returned.
Loads the workflow data or creates a new one . Reads the data stored in ` p ` file . Only file name section of ` p ` is used as data will be always saved in workflow ' s default data dir . If the file is missing or corrupt a new ( empty ) Data instance will be returned .
pub fn load<P: AsRef<Path>>(p: P) -> Result<Self, Error> {
        if p.as_ref().as_os_str().is_empty() {
            bail!("File name to load data from cannot be empty");
        }
        // Only use the file name section of input parameter. We will always save to Workflow's
        // data dir
        let filename = p
            .as_ref()
            .file_name()
            .ok_or_else(|| err_msg("invalid file name"))?;
        let wf_data_path = env::workflow_data().ok_or_else(|| {
            err_msg("missing env variable for data dir. forgot to set workflow bundle id?")
        })?;
        let wf_data_fn = wf_data_path.join(filename);
        let inner = Self::read_data_from_disk(&wf_data_fn)
            .or_else(|_| -> Result<_, Error> { Ok(HashMap::new()) })?;
        Ok(Data {
            inner,
            file_name: wf_data_fn,
        })
    }
pub fn load < P : AsRef < Path > > ( p : P ) -> Result < Self , Error > { if p . as_ref ( ) . as_os_str ( ) . is_empty ( ) { bail ! ( " " ) ; } // Only use the file name section of input parameter. We will always save to Workflow's // data dir let filename = p . as_ref ( ) . file_name ( ) . ok_or_else ( | | err_msg ( " " ) ) ? ; let wf_data_path = env :: workflow_data ( ) . ok_or_else ( | | { err_msg ( " " ) } ) ? ; let wf_data_fn = wf_data_path . join ( filename ) ; let inner = Self :: read_data_from_disk ( & wf_data_fn ) . or_else ( | _ | -> Result < _ , Error > { Ok ( HashMap :: new ( ) ) } ) ? ; Ok ( Data { inner , file_name : wf_data_fn , } ) }
Loads the workflow data or creates a new one.
Loads the workflow data or creates a new one .
p
P
errors:
This method can fail if any disk/IO error happens.
This method can fail if any disk / IO error happens .