pub fn add_module(
    modules_dir: &PathBuf,
    bytes: Vec<u8>,
    config: TomlFaaSNamedModuleConfig,
) -> Result<()> {
    let module = modules_dir.join(file_names::module_file_name(&config.name));
    std::fs::write(&module, bytes).map_err(|err| AddModule { path: module, err })?;

    // replace existing configuration with a new one
    let toml = toml::to_string_pretty(&config).map_err(|err| SerializeConfig { err })?;
    let config = modules_dir.join(file_names::module_config_name(config.name));
    std::fs::write(&config, toml).map_err(|err| WriteConfig { path: config, err })?;

    Ok(())
}
/// Adds a module to the filesystem, overwriting existing module.
/// Also adds module config to the TomlFaaSNamedModuleConfig
Adds a module to the filesystem, overwriting existing module.
Also adds module config to the TomlFaaSNamedModuleConfig
Adds a module to the filesystem overwriting existing module . Also adds module config to the TomlFaaSNamedModuleConfig
pub fn add_module(
    modules_dir: &PathBuf,
    bytes: Vec<u8>,
    config: TomlFaaSNamedModuleConfig,
) -> Result<()> {
    let module = modules_dir.join(file_names::module_file_name(&config.name));
    std::fs::write(&module, bytes).map_err(|err| AddModule { path: module, err })?;
    // replace existing configuration with a new one
    let toml = toml::to_string_pretty(&config).map_err(|err| SerializeConfig { err })?;
    let config = modules_dir.join(file_names::module_config_name(config.name));
    std::fs::write(&config, toml).map_err(|err| WriteConfig { path: config, err })?;
    Ok(())
}
pub fn add_module ( modules_dir : & PathBuf , bytes : Vec < u8 > , config : TomlFaaSNamedModuleConfig , ) -> Result < ( ) > { let module = modules_dir . join ( file_names :: module_file_name ( & config . name ) ) ; std :: fs :: write ( & module , bytes ) . map_err ( | err | AddModule { path : module , err } ) ? ; // replace existing configuration with a new one let toml = toml :: to_string_pretty ( & config ) . map_err ( | err | SerializeConfig { err } ) ? ; let config = modules_dir . join ( file_names :: module_config_name ( config . name ) ) ; std :: fs :: write ( & config , toml ) . map_err ( | err | WriteConfig { path : config , err } ) ? ; Ok ( ( ) ) }
Adds a module to the filesystem, overwriting existing module.
Adds a module to the filesystem overwriting existing module .
modules_dir
&PathBuf
bytes
Vec<u8>
config
TomlFaaSNamedModuleConfig