[](https://www.rust-lang.org)
[](https://crates.io/crates/native-svc)
[](https://docs.rs/native-svc)
[](LICENSE)
An HTTP adapter that implements the `embedded-svc` interface using `hyper` as the backend.
This library enables HTTP/HTTPS requests with a familiar synchronous API while leveraging the power and robustness of `hyper` under the hood.
- -----
Add this to your `Cargo.toml`:
```toml
[dependencies]
native-svc = "0.1.0"
๐ ๏ธ Usage
Simple GET Request
use HyperHttpConnection;
use Client;
POST Request with JSON
use HyperHttpConnection;
use Client;
use Write;
Error Handling
use ;
๐๏ธ Architecture
The library is organized into modules:
lib.rs: MainHyperHttpConnectionstructure and trait implementationserror.rs: Custom error types with detailed error handling
Implemented Traits
embedded_svc::http::client::Connection: Main interface for HTTP connectionsembedded_svc::io::Read: Reading response bodyembedded_svc::io::Write: Writing request bodyembedded_svc::http::Status: HTTP status accessembedded_svc::http::Headers: HTTP headers access
๐งช Testing
Run tests with:
Note: Integration tests require an Internet connection as they use httpbin.org.
๐ Performance
- Runtime: Uses Tokio with a multi-threaded runtime
- Memory: Default internal buffer of 8KB for write operations
- Connections: HTTPS connections support with connection reuse via
hyper
๐ Security
- Native TLS/SSL support via
hyper-tls
๐ค Contributing
Contributions are welcome! Here's how to contribute:
- Fork the project
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Development Guidelines
- Follow Rust naming conventions
- Add tests for new functionality
- Update documentation for public APIs
- Ensure
cargo clippypasses without warnings
๐ License
This project is licensed under MIT. See the LICENSE files for details.
๐ Compatibility
- Rust Version: 1.88.0 or later
- Platforms: All platforms supported by
tokioandhyper - HTTP Versions: HTTP/1.1
๐ Acknowledgments
- The hyper team for their excellent HTTP client
- The embedded-svc team for standardized traits
- The Rust community for the incredible ecosystem
๐ Known Issues
- Limited HTTP/2 support (HTTP/1.1 only currently)
Made with โค๏ธ in Rust