INNER CODE UNIT · Rust

add_job

tangle-network/blueprint · crates/blueprint-profiling/src/lib.rs:105

    pub fn add_job(&mut self, job_id: u32, profile: JobProfile) {
        self.jobs.insert(job_id, profile);
    }

    /// Save profiles to a JSON file
    ///
    /// Typically saved to `target/blueprint-profiles.json` in the blueprint workspace.
    pub fn save_to_file(&self, path: impl AsRef<std::path::Path>) -> Result<(), ProfilingError> {
        let json = serde_json::to_string_pretty(self).map_err(|e| {
            ProfilingError::InvalidConfiguration(format!("JSON serialization failed: {e}"))
        })?;

        std::fs::write(path.as_ref(), json).map_err(|e| {
            ProfilingError::InvalidConfiguration(format!("Failed to write file: {e}"))
        })?;

        Ok(())
    }

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…