Skip to content

Commit

Permalink
ldap: improve some rust style
Browse files Browse the repository at this point in the history
  • Loading branch information
catenacyber authored and victorjulien committed Oct 14, 2024
1 parent 97d525d commit 2fb89f1
Showing 1 changed file with 4 additions and 18 deletions.
22 changes: 4 additions & 18 deletions rust/src/ldap/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ impl<'a> From<ldap_parser::ldap::LdapMessage<'a>> for LdapMessage {
ldap_parser::ldap::ProtocolOp::IntermediateResponse(msg) => {
Self::from_intermediate_response(msg)
}
_ => ProtocolOp::Unknown,
ldap_parser::ldap::ProtocolOp::AbandonRequest(_) => ProtocolOp::Unknown,
};
let controls = ldap_msg.controls.map(|ctls| {
ctls.iter()
Expand Down Expand Up @@ -414,6 +414,7 @@ impl LdapMessage {
| ProtocolOp::DelRequest(_)
| ProtocolOp::ModDnRequest(_)
| ProtocolOp::CompareRequest(_)
| ProtocolOp::Unknown // AbandonRequest
| ProtocolOp::ExtendedRequest(_) => {
return true;
}
Expand All @@ -424,23 +425,8 @@ impl LdapMessage {
}

pub fn is_response(&self) -> bool {
match self.protocol_op {
ProtocolOp::BindResponse(_)
| ProtocolOp::SearchResultEntry(_)
| ProtocolOp::SearchResultReference(_)
| ProtocolOp::SearchResultDone(_)
| ProtocolOp::ModifyResponse(_)
| ProtocolOp::AddResponse(_)
| ProtocolOp::DelResponse(_)
| ProtocolOp::ModDnResponse(_)
| ProtocolOp::CompareResponse(_)
| ProtocolOp::ExtendedResponse(_) => {
return true;
}
_ => {
return false;
}
}
// it is either a response or a request
return !self.is_request();
}

fn from_bind_request(msg: ldap_parser::ldap::BindRequest) -> ProtocolOp {
Expand Down

0 comments on commit 2fb89f1

Please sign in to comment.