pub struct Pdu {
pub pdu_type: PduType,
pub request_id: i32,
pub error_status: i32,
pub error_index: i32,
pub varbinds: Vec<VarBind>,
}Expand description
Generic PDU structure for request/response operations.
Fields§
§pdu_type: PduTypePDU type
request_id: i32Request ID for correlating requests and responses
error_status: i32Error status (0 for requests, error code for responses)
error_index: i32Error index (1-based index of problematic varbind)
varbinds: Vec<VarBind>Variable bindings
Implementations§
Source§impl Pdu
impl Pdu
Sourcepub fn get_request(request_id: i32, oids: &[Oid]) -> Self
pub fn get_request(request_id: i32, oids: &[Oid]) -> Self
Create a new GET request PDU.
Sourcepub fn get_next_request(request_id: i32, oids: &[Oid]) -> Self
pub fn get_next_request(request_id: i32, oids: &[Oid]) -> Self
Create a new GETNEXT request PDU.
Sourcepub fn set_request(request_id: i32, varbinds: Vec<VarBind>) -> Self
pub fn set_request(request_id: i32, varbinds: Vec<VarBind>) -> Self
Create a new SET request PDU.
Sourcepub fn get_bulk(
request_id: i32,
non_repeaters: i32,
max_repetitions: i32,
varbinds: Vec<VarBind>,
) -> Self
pub fn get_bulk( request_id: i32, non_repeaters: i32, max_repetitions: i32, varbinds: Vec<VarBind>, ) -> Self
Create a GETBULK request PDU.
Note: For GETBULK, error_status holds non_repeaters and error_index holds max_repetitions.
Sourcepub fn decode(decoder: &mut Decoder) -> Result<Self>
pub fn decode(decoder: &mut Decoder) -> Result<Self>
Decode from BER (after tag has been peeked).
Sourcepub fn error_status_enum(&self) -> ErrorStatus
pub fn error_status_enum(&self) -> ErrorStatus
Get the error status as an enum.
Sourcepub fn to_response(&self) -> Self
pub fn to_response(&self) -> Self
Create a Response PDU from this PDU (for Inform handling).
The response copies the request_id and variable bindings, sets error_status and error_index to 0, and changes the PDU type to Response.
Sourcepub fn to_error_response(
&self,
error_status: ErrorStatus,
error_index: i32,
) -> Self
pub fn to_error_response( &self, error_status: ErrorStatus, error_index: i32, ) -> Self
Create a Response PDU with specific error status.
Sourcepub fn is_notification(&self) -> bool
pub fn is_notification(&self) -> bool
Check if this is a notification PDU (Trap or Inform).
Sourcepub fn is_confirmed(&self) -> bool
pub fn is_confirmed(&self) -> bool
Check if this is a confirmed-class PDU (requires response).