Skip to content

Commit

Permalink
Add Clone and Debug traits to most objects
Browse files Browse the repository at this point in the history
  • Loading branch information
chifflier committed Feb 29, 2024
1 parent 08c6e73 commit 1139837
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 34 deletions.
22 changes: 11 additions & 11 deletions src/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use crate::ldap::LdapString;
use std::borrow::Cow;

#[derive(Debug, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum Filter<'a> {
And(Vec<Filter<'a>>),
Or(Vec<Filter<'a>>),
Expand All @@ -17,53 +17,53 @@ pub enum Filter<'a> {
ExtensibleMatch(MatchingRuleAssertion<'a>),
}

#[derive(Debug, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct PartialAttribute<'a> {
pub attr_type: LdapString<'a>,
pub attr_vals: Vec<AttributeValue<'a>>,
}

#[derive(Debug, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Attribute<'a> {
pub attr_type: LdapString<'a>,
pub attr_vals: Vec<AttributeValue<'a>>,
}

#[derive(Debug, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct AttributeValueAssertion<'a> {
pub attribute_desc: LdapString<'a>,
pub assertion_value: &'a [u8],
}

#[derive(Debug, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct AttributeDescription<'a>(pub Cow<'a, str>);

#[derive(Debug, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct MatchingRuleAssertion<'a> {
pub matching_rule: Option<LdapString<'a>>,
pub rule_type: Option<AttributeDescription<'a>>,
pub assertion_value: AssertionValue<'a>,
pub dn_attributes: Option<bool>,
}

#[derive(Debug, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct MatchingRuleId<'a>(pub Cow<'a, str>);

#[derive(Debug, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct SubstringFilter<'a> {
pub filter_type: LdapString<'a>,
pub substrings: Vec<Substring<'a>>,
}

#[derive(Debug, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum Substring<'a> {
Initial(AssertionValue<'a>),
Any(AssertionValue<'a>),
Final(AssertionValue<'a>),
}

#[derive(Debug, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct AssertionValue<'a>(pub Cow<'a, [u8]>);

#[derive(Debug, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct AttributeValue<'a>(pub Cow<'a, [u8]>);
46 changes: 23 additions & 23 deletions src/ldap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,52 +126,52 @@ impl debug Operation {
}
}

#[derive(Debug, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct LdapString<'a>(pub Cow<'a, str>);

#[derive(Debug, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct LdapDN<'a>(pub Cow<'a, str>);

#[derive(Debug, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct RelativeLdapDN<'a>(pub Cow<'a, str>);

#[derive(Debug, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct LdapOID<'a>(pub Cow<'a, str>);

#[derive(Debug, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct LdapResult<'a> {
pub result_code: ResultCode,
pub matched_dn: LdapDN<'a>,
pub diagnostic_message: LdapString<'a>,
// referral [3] Referral OPTIONAL
}

#[derive(Debug, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct BindRequest<'a> {
pub version: u8,
pub name: LdapDN<'a>,
pub authentication: AuthenticationChoice<'a>,
}

#[derive(Debug, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct SaslCredentials<'a> {
pub mechanism: LdapString<'a>,
pub credentials: Option<Cow<'a, [u8]>>,
}

#[derive(Debug, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum AuthenticationChoice<'a> {
Simple(Cow<'a, [u8]>),
Sasl(SaslCredentials<'a>),
}

#[derive(Debug, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct BindResponse<'a> {
pub result: LdapResult<'a>,
pub server_sasl_creds: Option<Cow<'a, [u8]>>,
}

#[derive(Debug, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct SearchRequest<'a> {
pub base_object: LdapDN<'a>,
pub scope: SearchScope,
Expand All @@ -183,69 +183,69 @@ pub struct SearchRequest<'a> {
pub attributes: Vec<LdapString<'a>>,
}

#[derive(Debug, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct SearchResultEntry<'a> {
pub object_name: LdapDN<'a>,
pub attributes: Vec<PartialAttribute<'a>>,
}

#[derive(Debug, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct ModifyRequest<'a> {
pub object: LdapDN<'a>,
pub changes: Vec<Change<'a>>,
}

#[derive(Debug, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct ModifyResponse<'a> {
pub result: LdapResult<'a>,
}

#[derive(Debug, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Change<'a> {
pub operation: Operation,
pub modification: PartialAttribute<'a>,
}

#[derive(Debug, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct AddRequest<'a> {
pub entry: LdapDN<'a>,
pub attributes: Vec<Attribute<'a>>,
}

#[derive(Debug, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct ModDnRequest<'a> {
pub entry: LdapDN<'a>,
pub newrdn: RelativeLdapDN<'a>,
pub deleteoldrdn: bool,
pub newsuperior: Option<LdapDN<'a>>,
}

#[derive(Debug, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct CompareRequest<'a> {
pub entry: LdapDN<'a>,
pub ava: AttributeValueAssertion<'a>,
}

#[derive(Debug, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct ExtendedRequest<'a> {
pub request_name: LdapOID<'a>,
pub request_value: Option<Cow<'a, [u8]>>,
}

#[derive(Debug, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct ExtendedResponse<'a> {
pub result: LdapResult<'a>,
pub response_name: Option<LdapOID<'a>>,
pub response_value: Option<Cow<'a, [u8]>>,
}

#[derive(Debug, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct IntermediateResponse<'a> {
pub response_name: Option<LdapOID<'a>>,
pub response_value: Option<Cow<'a, [u8]>>,
}

#[derive(Debug, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum ProtocolOp<'a> {
BindRequest(BindRequest<'a>),
BindResponse(BindResponse<'a>),
Expand Down Expand Up @@ -316,7 +316,7 @@ impl<'a> ProtocolOp<'a> {
}
}

#[derive(Debug, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Control<'a> {
pub control_type: LdapOID<'a>,
pub criticality: bool,
Expand Down Expand Up @@ -378,7 +378,7 @@ pub struct Control<'a> {
/// }
/// # }
/// ```
#[derive(Debug, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct LdapMessage<'a> {
/// Message Identifier (32-bits unsigned integer)
///
Expand Down

0 comments on commit 1139837

Please sign in to comment.