Expand description
§Butterfly-dl Library
A high-performance, memory-efficient library for downloading OpenStreetMap data files with intelligent source routing and minimal memory usage.
§Features
- Smart source routing: S3 for planet files, HTTP for regional extracts
- Memory efficient: <1GB RAM usage regardless of file size
- Streaming support: Download directly to any AsyncWrite destination
- Progress tracking: Optional progress callbacks for custom UIs
- Feature flags: Optional S3 support to minimize dependencies
§Basic Usage
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Download to file with auto-generated filename
butterfly_dl::get("europe/belgium", None).await?;
// Download to specific file
butterfly_dl::get("planet", Some("./planet.pbf")).await?;
// Stream download
let mut stream = butterfly_dl::get_stream("europe/monaco").await?;
// Use stream with any AsyncRead-compatible code
Ok(())
}§Progress Tracking
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
butterfly_dl::get_with_progress(
"europe/belgium",
Some("belgium.pbf"),
|downloaded, total| {
println!("Progress: {}/{} bytes", downloaded, total);
}
).await?;
Ok(())
}Structs§
- Download
Options - Options for download operations
- Downloader
- Advanced API: Create a downloader with custom configuration
- Source
Config - Advanced API: Create a downloader with custom configuration
Enums§
- Error
- Main error type for butterfly-osm operations
- Overwrite
Behavior - Overwrite behavior for existing files
Functions§
- get
- Download a file to a destination
- get_
stream - Download and return a stream
- get_
with_ options - Download with custom options
- get_
with_ progress - Download with progress tracking
Type Aliases§
- Result
- Convenience result type for butterfly-osm operations