save_text

Function save_text 

Source
pub async fn save_text(url: &str, content: &str) -> Result<(), Box<dyn Error>>
Expand description

Saves the text content to a file

The file will be created in the data/txt/ directory with a name based on the URL

§Arguments

  • url - The source URL (used to generate the file name)
  • content - The text content to save

§Exemples

use gitbook2text::save_text;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    save_text("https://example.com/page", "Contenu texte").await?;
    Ok(())
}

§Errors

Returns an error if writing the file fails