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
impl RequestRegistration
Sourcepub fn community(
request_id: i32,
deadline: Instant,
version: CommunityVersion,
community: impl Into<Community>,
policy: CommunityResponsePolicy,
) -> Self
pub fn community( request_id: i32, deadline: Instant, version: CommunityVersion, community: impl Into<Community>, policy: CommunityResponsePolicy, ) -> Self
Construct v1/v2c registration metadata.
Sourcepub fn with_aliases(
self,
aliases: impl IntoIterator<Item = i32>,
) -> Result<Self>
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.
Sourcepub const fn with_decode_config(self, config: DecodeConfig) -> Self
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.
Sourcepub const fn decode_config(&self) -> DecodeConfig
pub const fn decode_config(&self) -> DecodeConfig
Decode configuration used by correlation and full validation.
Sourcepub const fn request_id(&self) -> i32
pub const fn request_id(&self) -> i32
Primary request ID (v1/v2c) or message ID (v3).
Sourcepub const fn deadline(&self) -> Instant
pub const fn deadline(&self) -> Instant
Absolute deadline covering registration, write, and response validation.
Sourcepub fn evaluate_response_identity(
&self,
data: &[u8],
source_is_target: bool,
) -> ResponseIdentity
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
impl Clone for RequestRegistration
Source§fn clone(&self) -> RequestRegistration
fn clone(&self) -> RequestRegistration
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more