docs.rs failed to build moosicbox_files-0.2.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build:
moosicbox_files-0.1.4
MoosicBox Files
A comprehensive file handling and streaming utility library for the MoosicBox ecosystem. Provides functions for downloading, saving, and managing files with support for progress monitoring, cover art extraction, audio track streaming, and HTTP API endpoints for serving media content.
Features
Core features (always available):
- File Download: Download files from remote URLs with HTTP client support
- Stream Saving: Save byte streams to files with progress monitoring
- Progress Tracking: Monitor download progress and speed during file operations
- Cover Art Handling: Extract and save album cover art from audio tags
- Content Length Detection: Get remote file sizes via HTTP HEAD requests
- Filename Sanitization: Clean filenames for filesystem compatibility
- Error Handling: Detailed error types for different failure scenarios
With optional features enabled:
- Track Management: Handle audio track files, metadata, and streaming with pooling support (requires
filesfeature) - Album/Artist Artwork: Fetch, cache, and manage album and artist cover images (requires
filesfeature) - HTTP Range Support: Parse HTTP byte range requests (requires
rangefeature); enable/trackrange responses withtrack-range - REST API Endpoints: Actix-web endpoints for serving files, tracks, and artwork (requires
apifeature) - Audio Codec Support: Decode/encode various audio formats including AAC, FLAC, MP3, and Opus (requires decoder/encoder features)
Installation
Add this to your Cargo.toml:
[]
= "0.1.4"
# Enable additional features
# moosicbox_files = { version = "0.1.4", features = ["files", "range", "api"] }
Usage
Basic File Operations
use ;
use Path;
Downloading Files from URLs
use ;
use Client;
use Path;
async
Streaming with Progress Monitoring
use ;
use Client;
use Path;
use Pin;
use Future;
async
Speed Monitoring
use ;
use Client;
use Path;
use Pin;
use Future;
async
Cover Art Handling
use search_for_cover;
use AudioTag;
use PathBuf;
async
Custom Headers and Range Requests
use ;
use Client;
async
API Reference
Core Functions (always available)
save_bytes_to_file()- Save byte array to file with optional offsetsave_bytes_stream_to_file()- Save async byte stream to filefetch_bytes_from_remote_url()- Get byte stream from URLfetch_and_save_bytes_from_remote_url()- Download and save in one operationget_content_length()- Get remote file size via HTTP HEADsanitize_filename()- Clean filename for filesystem use
Progress Monitoring (always available)
save_bytes_stream_to_file_with_progress_listener()- Save with progress callbackssave_bytes_stream_to_file_with_speed_listener()- Save with speed monitoring
Cover Art Support (always available)
search_for_cover()- Find existing cover or extract from audio tags
Additional Modules (feature-gated)
With the files feature enabled:
files::track- Track file management and streamingfiles::album- Album cover art handlingfiles::artist- Artist artwork handlingfiles::track_pool- Track pooling and caching
With the api feature enabled:
api- Actix-web endpoints for file serving, track streaming, and artwork deliveryapi::bind_services(scope)- Register all files endpoints on an ActixScope
With the range feature enabled:
range- HTTP byte range parsing utilitiesrange::Range- Range type with optionalstart/endboundsrange::parse_range()/range::parse_ranges()- Parse one or more byte range expressions
Error Handling
The library provides specific error types for different operations:
GetContentLengthError- HTTP or parsing errors when getting content lengthSaveBytesStreamToFileError- IO errors during stream-to-file operationsFetchAndSaveBytesFromRemoteUrlError- Network or file errors during downloadsFetchCoverError- Errors when handling cover art operations
Cargo Features
The package provides several optional features:
files- Enable track management, album/artist handling, and audio file poolingrange- Enable HTTP range request supporttrack-range- Enable byte-range handling on the/trackAPI endpointapi- Enable Actix-web API endpoints for file serving (impliesfilesandrange)openapi- Enable OpenAPI/utoipa documentation supportimage- Enable image processing withmoosicbox_imagelibvips- Enable libvips backend for image processingprofiling- Enable profiling support
Audio format features (decoder/encoder support):
all-decoders/all-encoders- Enable all supported codecsdecoder-aac,decoder-flac,decoder-mp3,decoder-opus- Individual decoder featuresencoder-aac,encoder-flac,encoder-mp3,encoder-opus- Individual encoder features
Dependencies
Core dependencies:
switchy_http- HTTP client functionality with streaming supportswitchy_fs- Cross-platform async filesystem operationsswitchy_time- Cross-platform time utilitiesmoosicbox_audiotags- Audio tag parsing for cover art extractionmoosicbox_stream_utils- Stream monitoring and utilitiesmoosicbox_config- Configuration managementtokio- Async runtime supportbytes- Efficient byte buffer managementfutures- Asynchronous stream processing
Optional dependencies (enabled by features):
actix-web/actix-files- Web server framework (withapifeature)moosicbox_music_api/moosicbox_music_models- Music API integration (withfilesfeature)moosicbox_audio_decoder/moosicbox_audio_output- Audio processing (with decoder/encoder features)moosicbox_image- Image processing (withimagefeature)utoipa- OpenAPI documentation (withopenapifeature)