reqwest-builder-0.2.0 has been yanked.
Reqwest Builder
A builder for reqwest requests with support for custom headers, query parameters, and body content, featuring comprehensive error handling.
Features
- ✅ Builder Pattern: Trait-based approach for converting request structures into reqwest builders
- ✅ Multiple Body Types: Support for JSON, form-encoded, multipart, and no-body requests
- ✅ Error Handling: Comprehensive error handling with detailed error messages
- ✅ File Uploads: Built-in support for file uploads with MIME type detection
- ✅ Header Management: Safe header serialization with proper error reporting
- ✅ Backward Compatibility: Maintains compatibility with existing code
- ✅ Modular Architecture: Clean separation of concerns with well-organized modules
Error Handling
The library provides two approaches for error handling:
1. Backward Compatible (Silent Failures)
use ;
// This method silently skips invalid headers/data
let builder = request.into_reqwest_builder;
2. Explicit Error Handling (Recommended)
use ;
// This method returns detailed errors
match request.try_into_reqwest_builder
Error Types
The library provides detailed error information through the ReqwestBuilderError enum:
SerializationError: Issues with JSON serializationHeaderError: Invalid header names or valuesUrlError: URL construction problemsIoError: File I/O errorsInvalidRequest: General request configuration issues
Usage Example
use ;
use Serialize;
async
File Upload Example
use ;
// Create file upload with error handling
let file = from_path?;
// Or create from bytes
let file = from_bytes;