pub struct HttpBackend { /* private fields */ }Expand description
HTTP storage backend with embedded Tokio runtime.
This backend wraps an async reqwest::Client and Tokio Runtime to provide
synchronous StorageBackend operations while leveraging async I/O internally.
It validates URLs for security, maintains a connection pool, and performs
range requests to fetch specific byte ranges.
§Examples
use hexz_core::store::http::HttpBackend;
use hexz_core::store::StorageBackend;
let backend = HttpBackend::new(
"https://example.com/snapshot.hxz".to_string(),
false
)?;
let data = backend.read_exact(8192, 4096)?;
assert_eq!(data.len(), 4096);Implementations§
Source§impl HttpBackend
impl HttpBackend
Sourcepub fn new(url: String, allow_restricted: bool) -> Result<Self>
pub fn new(url: String, allow_restricted: bool) -> Result<Self>
Creates a new HTTP backend by validating the URL and fetching file metadata.
This constructor:
- Validates the URL for security (blocks restricted IPs unless allowed)
- Creates a Tokio runtime for executing async operations
- Sends an async HEAD request to verify the server and fetch file size
- Extracts the
Content-Lengthheader to determine snapshot size
§Parameters
url: The HTTP/HTTPS URL of the snapshot fileallow_restricted: Iffalse, blocks access to localhost and private networks
Trait Implementations§
Source§impl Debug for HttpBackend
impl Debug for HttpBackend
Auto Trait Implementations§
impl Freeze for HttpBackend
impl !RefUnwindSafe for HttpBackend
impl Send for HttpBackend
impl Sync for HttpBackend
impl Unpin for HttpBackend
impl UnsafeUnpin for HttpBackend
impl !UnwindSafe for HttpBackend
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more