pub struct AntProtocol { /* private fields */ }Expand description
ANT protocol handler.
Handles chunk PUT/GET/Quote requests using LMDB storage for persistence and optional payment verification.
Implementations§
Source§impl AntProtocol
impl AntProtocol
Sourcepub fn new(
storage: Arc<LmdbStorage>,
payment_verifier: Arc<PaymentVerifier>,
quote_generator: Arc<QuoteGenerator>,
) -> Self
pub fn new( storage: Arc<LmdbStorage>, payment_verifier: Arc<PaymentVerifier>, quote_generator: Arc<QuoteGenerator>, ) -> Self
Create a new ANT protocol handler.
§Arguments
storage- LMDB storage for chunk persistencepayment_verifier- Payment verifier for validating paymentsquote_generator- Quote generator for creating storage quotes
Sourcepub fn protocol_id(&self) -> &'static str
pub fn protocol_id(&self) -> &'static str
Get the protocol identifier.
Sourcepub async fn try_handle_request(&self, data: &[u8]) -> Result<Option<Bytes>>
pub async fn try_handle_request(&self, data: &[u8]) -> Result<Option<Bytes>>
Handle an incoming request and produce a response.
Decodes the raw message, processes it if it is a request variant,
and returns the encoded response bytes. Returns Ok(None) for
response messages (which are meant for client subscribers, not for
the protocol handler).
§Errors
Returns an error if message decoding, handling, or encoding fails.
Sourcepub fn storage_stats(&self) -> StorageStats
pub fn storage_stats(&self) -> StorageStats
Get storage statistics.
Sourcepub fn payment_cache_stats(&self) -> CacheStats
pub fn payment_cache_stats(&self) -> CacheStats
Get payment cache statistics.
Auto Trait Implementations§
impl Freeze for AntProtocol
impl !RefUnwindSafe for AntProtocol
impl Send for AntProtocol
impl Sync for AntProtocol
impl Unpin for AntProtocol
impl UnsafeUnpin for AntProtocol
impl !UnwindSafe for AntProtocol
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