Skip to main content

load_backup

Function load_backup 

Source
pub fn load_backup(path: &Path) -> Result<Vec<u8>>
Expand description

Load file content into memory as a backup before editing.

Reads the entire file content into a byte vector. This is used to detect if the file was actually modified by comparing before/after content.

§Arguments

  • path - Path to the file to backup

§Returns

  • Ok(Vec<u8>) containing the file content
  • Err if:
    • File does not exist
    • Permission denied reading the file
    • I/O error occurs

§Examples

let backup = load_backup(Path::new(".beans/1-my-task.md"))?;