pub struct CommunityMessage {
pub version: Version,
pub community: Bytes,
pub pdu: CommunityPdu,
}Expand description
Community-based SNMP message (v1/v2c).
This unified type handles both SNMPv1 and SNMPv2c messages,
which share identical structure but differ in version number.
The pdu field is a CommunityPdu that can hold either a standard
PDU or a TrapV1 PDU.
Fields§
§version: VersionSNMP version (V1 or V2c)
community: BytesCommunity string for authentication
pdu: CommunityPduProtocol data unit
Implementations§
Source§impl CommunityMessage
impl CommunityMessage
Sourcepub fn new(version: Version, community: impl Into<Bytes>, pdu: Pdu) -> Self
pub fn new(version: Version, community: impl Into<Bytes>, pdu: Pdu) -> Self
Create a new community message with a standard PDU.
§Panics
Panics if version is V3 (use V3Message instead).
Sourcepub fn v2c(community: impl Into<Bytes>, pdu: Pdu) -> Self
pub fn v2c(community: impl Into<Bytes>, pdu: Pdu) -> Self
Create a V2c message (convenience constructor).
Sourcepub fn v1(community: impl Into<Bytes>, pdu: Pdu) -> Self
pub fn v1(community: impl Into<Bytes>, pdu: Pdu) -> Self
Create a V1 message with a standard PDU (convenience constructor).
Sourcepub fn v1_trap(community: impl Into<Bytes>, trap: TrapV1Pdu) -> Self
pub fn v1_trap(community: impl Into<Bytes>, trap: TrapV1Pdu) -> Self
Create a V1 message carrying a TrapV1 PDU.
Sourcepub fn decode(data: Bytes) -> Result<Self>
pub fn decode(data: Bytes) -> Result<Self>
Decode from BER.
Returns the message with the version parsed from the data.
Sourcepub fn into_pdu(self) -> Option<Pdu>
pub fn into_pdu(self) -> Option<Pdu>
Consume and return the standard PDU.
Returns None if the PDU is a TrapV1.
Sourcepub fn into_community_pdu(self) -> CommunityPdu
pub fn into_community_pdu(self) -> CommunityPdu
Consume and return the CommunityPdu.
Sourcepub fn encode_bulk(
version: Version,
community: impl Into<Bytes>,
pdu: &GetBulkPdu,
) -> Bytes
pub fn encode_bulk( version: Version, community: impl Into<Bytes>, pdu: &GetBulkPdu, ) -> Bytes
Encode a GETBULK request message (v2c/v3 only).
GETBULK is not supported in SNMPv1.
Trait Implementations§
Source§impl Clone for CommunityMessage
impl Clone for CommunityMessage
Source§fn clone(&self) -> CommunityMessage
fn clone(&self) -> CommunityMessage
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CommunityMessage
impl Debug for CommunityMessage
Source§impl From<CommunityMessage> for Message
impl From<CommunityMessage> for Message
Source§fn from(msg: CommunityMessage) -> Self
fn from(msg: CommunityMessage) -> Self
Auto Trait Implementations§
impl !Freeze for CommunityMessage
impl RefUnwindSafe for CommunityMessage
impl Send for CommunityMessage
impl Sync for CommunityMessage
impl Unpin for CommunityMessage
impl UnsafeUnpin for CommunityMessage
impl UnwindSafe for CommunityMessage
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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