swarm-scout 0.6.1

scout — a light, no-node client for reading content from Swarm: point at a gateway (or any Bee) and cat / get / bytes by reference.
Documentation
//! Read content from Swarm with no node — just a gateway.
//!
//!   cargo run --example read -- <reference>
//!   BEE_GATEWAY=https://download.gateway.ethswarm.org cargo run --example read -- <ref>

use scout::LiteClient;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let reference = std::env::args()
        .nth(1)
        .expect("usage: read <reference> [path]");
    let path = std::env::args().nth(2);
    let gateway = std::env::var("BEE_GATEWAY")
        .unwrap_or_else(|_| "https://download.gateway.ethswarm.org".into());

    let scout = LiteClient::read(&gateway)?;
    let data = match &path {
        Some(p) => scout.cat_path(&reference, p).await?,
        None => scout.cat(&reference).await?,
    };
    print!("{}", String::from_utf8_lossy(&data));
    Ok(())
}