pub struct GatewayPool { /* private fields */ }Expand description
Ordered pool of IPFS HTTP gateways with hedged failover and per-gateway Fibonacci cooldowns.
Read-only: fetches content and resolves IPNS paths. Publishing, pinning
and key management belong to the Kubo client (crate::kubo), never here.
Implementations§
Source§impl GatewayPool
impl GatewayPool
Sourcepub fn public_default() -> Self
pub fn public_default() -> Self
Build a public-gateway pool with no localhost probing.
Sourcepub fn new(gateway_url: impl Into<String>) -> Self
pub fn new(gateway_url: impl Into<String>) -> Self
Build a pool using the caller-provided primary gateway followed by
the standard public fallbacks. Localhost is used only if gateway_url
itself points at localhost.
Sourcepub fn local_first(gateway_url: impl Into<String>) -> Self
pub fn local_first(gateway_url: impl Into<String>) -> Self
Build a local-first pool: localhost, then the caller-provided primary gateway, then the standard public fallbacks.
Sourcepub fn with_base_cooldown(self, cooldown: Duration) -> Self
pub fn with_base_cooldown(self, cooldown: Duration) -> Self
Override the base cooldown applied after a gateway failure.
The cooldown escalates Fibonacci-style per consecutive failure and
resets on success. Duration::ZERO disables cooldowns entirely.
Sourcepub fn with_request_timeout(self, timeout: Duration) -> Self
pub fn with_request_timeout(self, timeout: Duration) -> Self
Override the per-request timeout (default 6 seconds). The timeout covers the whole request, connection through body transfer, and is clamped to the time remaining before the operation deadline.
Sourcepub fn set_request_timeout(&self, timeout: Option<Duration>)
pub fn set_request_timeout(&self, timeout: Option<Duration>)
Update the per-request timeout at runtime.
Pass None to revert to the 6-second built-in default.
Sourcepub async fn fetch<T>(
&self,
path: &str,
accept: Option<&str>,
parse: impl Fn(&[u8]) -> Result<T, String>,
) -> Result<T, String>
pub async fn fetch<T>( &self, path: &str, accept: Option<&str>, parse: impl Fn(&[u8]) -> Result<T, String>, ) -> Result<T, String>
GET path from the gateway pool until parse accepts a body.
Gateways are tried in cooldown-filtered order, hedged: a pending
attempt that has not answered within HEDGE_DELAY gets the next
gateway raced against it and the first parsed success wins. Failing
gateways earn an escalating Fibonacci cooldown; the whole operation
is bounded by TOTAL_DEADLINE. On total failure the per-gateway
errors are joined into one string for the caller to wrap.
Sourcepub async fn fetch_bytes(
&self,
path: &str,
accept: Option<&str>,
) -> Result<Vec<u8>, String>
pub async fn fetch_bytes( &self, path: &str, accept: Option<&str>, ) -> Result<Vec<u8>, String>
Fetch raw bytes for path (e.g. /ipfs/<cid>) with gateway failover.
Sourcepub async fn resolve_ipns_path(&self, path: &str) -> Result<String>
pub async fn resolve_ipns_path(&self, path: &str) -> Result<String>
Resolve an /ipns/<name> reference to its current /ipfs/<cid> path.
Reads only gateway response metadata, never the referenced content
body. Gateways commonly expose the resolved content path in
X-Ipfs-Path; redirects to /ipfs/... are accepted as a fallback.
Uses the same hedged failover and cooldowns as GatewayPool::fetch.
Trait Implementations§
Source§impl Default for GatewayPool
impl Default for GatewayPool
Source§impl From<GatewayPool> for IpfsGatewayResolver
impl From<GatewayPool> for IpfsGatewayResolver
Source§fn from(pool: GatewayPool) -> Self
fn from(pool: GatewayPool) -> Self
Auto Trait Implementations§
impl !Freeze for GatewayPool
impl !RefUnwindSafe for GatewayPool
impl !UnwindSafe for GatewayPool
impl Send for GatewayPool
impl Sync for GatewayPool
impl Unpin for GatewayPool
impl UnsafeUnpin for GatewayPool
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> ⓘ
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> ⓘ
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