Skip to content

Commit

Permalink
docs(image_ops): write documentation comments
Browse files Browse the repository at this point in the history
  • Loading branch information
walker84837 committed Dec 13, 2024
1 parent 6b3baf6 commit 6c6e215
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/image_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,28 @@ fn load_svg(contents: &[u8], size: u32) -> Result<Pixmap> {
Ok(pixmap)
}

/// Save an image to a file
/// Fails when the format is not supported, or when saving fails
/// # Examples:
/// Save an SVG image
/// ```rust
/// use ciphercanvas::save_image;
/// let image = "<svg>...</svg>";
/// let format = "svg";
/// let size = 128;
/// let output = PathBuf::from("output.svg");
/// save_image(&output, &format, &image, size).unwrap();
/// ```
///
/// Save a PNG image
/// ```rust
/// use ciphercanvas::save_image;
/// let image = "<svg>...</svg>";
/// let format = "png";
/// let size = 128;
/// let output = PathBuf::from("output.png");
/// save_image(&output, &format, &image, size).unwrap();
/// ```
pub fn save_image(output: &PathBuf, format: &str, image: &str, size: u32) -> Result<()> {
const SUPPORTED_FORMATS: &[&str] = &["svg", "png"];
info!(
Expand Down

0 comments on commit 6c6e215

Please sign in to comment.