flarer 0.1.0

Rust client and CLI for Cloudflare's Browser Rendering REST API (content, screenshot, PDF, snapshot, markdown, scrape, JSON extraction, links, crawl).
Documentation
//! The set of Browser Rendering tools exposed by Cloudflare.

use serde::{Deserialize, Serialize};
use strum::{Display, EnumIter, EnumString, IntoStaticStr, VariantNames};

/// One of the Cloudflare Browser Rendering REST endpoints.
///
/// Variant `Display` and `FromStr` use lowercase names matching the
/// Cloudflare URL path segment (e.g. `Tool::Content` ↔ `"content"`).
#[derive(
    Debug,
    Clone,
    Copy,
    PartialEq,
    Eq,
    Hash,
    Serialize,
    Deserialize,
    Display,
    EnumString,
    EnumIter,
    IntoStaticStr,
    VariantNames,
)]
#[strum(serialize_all = "lowercase")]
#[serde(rename_all = "lowercase")]
#[cfg_attr(feature = "cli", derive(clap::ValueEnum))]
#[cfg_attr(feature = "cli", clap(rename_all = "lowercase"))]
pub enum Tool {
    /// Returns the rendered HTML of a page.
    Content,
    /// Returns a PNG screenshot.
    Screenshot,
    /// Returns a PDF render.
    Pdf,
    /// Returns a snapshot containing both screenshot and HTML.
    Snapshot,
    /// Returns a Markdown rendering of the page.
    Markdown,
    /// Scrapes structured content from the page.
    Scrape,
    /// Extracts JSON via an LLM-backed endpoint.
    Json,
    /// Returns links discovered on the page.
    Links,
    /// Crawls a site (bounded).
    Crawl,
}

impl Tool {
    /// Lowercase URL path segment, e.g. `"content"`.
    pub fn as_path(self) -> &'static str {
        self.into()
    }
}