Skip to main content

RequestRegistration

Struct RequestRegistration 

Source
pub struct RequestRegistration { /* private fields */ }
Expand description

Correlation metadata for an in-flight request.

Construct registrations with Self::community or Self::v3. Identity, community, and deadline metadata is read-only after construction; aliases are normalized and bounded by Self::with_aliases.

use async_snmp::RequestRegistration;
use tokio::time::{Duration, Instant};

let mut registration = RequestRegistration::v3(7, Instant::now() + Duration::from_secs(1));
registration.request_id = 8;

Protocol-specific correlation details are intentionally internal rather than a separately constructible public enum:

use async_snmp::transport::ResponseCorrelation;

Community registrations accept only CommunityVersion, so an SNMPv3 registration cannot be constructed through the community API:

use async_snmp::{CommunityResponsePolicy, RequestRegistration, Version};
use bytes::Bytes;
use tokio::time::{Duration, Instant};

RequestRegistration::community(
    7,
    Instant::now() + Duration::from_secs(1),
    Version::V3,
    Bytes::from_static(b"public"),
    CommunityResponsePolicy::Exact,
);

Implementations§

Source§

impl RequestRegistration

Source

pub fn community( request_id: i32, deadline: Instant, version: CommunityVersion, community: impl Into<Community>, policy: CommunityResponsePolicy, ) -> Self

Construct v1/v2c registration metadata.

Source

pub fn v3(request_id: i32, deadline: Instant) -> Self

Construct SNMPv3 registration metadata.

Source

pub fn with_aliases( self, aliases: impl IntoIterator<Item = i32>, ) -> Result<Self>

Attach prior transmission IDs to this registration.

The primary ID and duplicate aliases are omitted so transports can reserve and correlate one coherent set of IDs.

Source

pub const fn with_decode_config(self, config: DecodeConfig) -> Self

Attach the decode configuration snapshot used for this exchange.

The default is DecodeConfig::DEFAULT, matching the client decode default. Compatible correlation accepts a bounded UDP datagram suffix after one complete declared SNMP message TLV as an explicit deviation from RFC 3417’s one-message-per-datagram mapping. Strict correlation rejects such a suffix before invoking the response validator. In either mode, identity fields are read only from the declared top-level envelope.

Source

pub const fn decode_config(&self) -> DecodeConfig

Decode configuration used by correlation and full validation.

Source

pub const fn request_id(&self) -> i32

Primary request ID (v1/v2c) or message ID (v3).

Source

pub const fn deadline(&self) -> Instant

Absolute deadline covering registration, write, and response validation.

Source

pub fn aliases(&self) -> &BTreeSet<i32>

Prior transmission IDs accepted for this operation.

Source

pub fn evaluate_response_identity( &self, data: &[u8], source_is_target: bool, ) -> ResponseIdentity

Evaluate transport-level response identity without consuming the exchange.

This checks the outer request ID (or SNMPv3 msgID) against the primary ID and aliases, verifies the registered protocol version, and applies the configured community response policy. source_is_target must report whether the packet source equals the transport’s configured target.

A matching identity is only a candidate. Callers must still decode and validate the response PDU and, for SNMPv3, perform the required security and scoped-PDU checks before accepting it.

Trait Implementations§

Source§

impl Clone for RequestRegistration

Source§

fn clone(&self) -> RequestRegistration

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RequestRegistration

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more