1use bytes::Bytes;
4pub use rasn_ldap::{AttributeValue, ResultCode, SearchRequestDerefAliases, SearchRequestScope};
5
6#[derive(Clone, Debug, Eq, PartialEq)]
8pub struct Attribute {
9 pub name: String,
11 pub values: Vec<Bytes>,
13}
14
15pub type Attributes = Vec<Attribute>;
16
17impl From<rasn_ldap::PartialAttribute> for Attribute {
18 fn from(raw: rasn_ldap::PartialAttribute) -> Self {
19 Attribute {
20 name: raw.r#type.0,
21 values: raw
22 .vals
23 .to_vec()
24 .into_iter()
25 .map(|v| Bytes::copy_from_slice(v))
26 .collect(),
27 }
28 }
29}
30
31impl From<Attribute> for rasn_ldap::PartialAttribute {
32 fn from(attr: Attribute) -> Self {
33 rasn_ldap::PartialAttribute::new(
34 attr.name.into(),
35 attr.values
36 .into_iter()
37 .map(|value| AttributeValue::from(value.as_ref()))
38 .collect::<Vec<_>>()
39 .into(),
40 )
41 }
42}
43
44impl From<Attribute> for rasn_ldap::Attribute {
45 fn from(attr: Attribute) -> Self {
46 rasn_ldap::Attribute::new(
47 attr.name.into(),
48 attr.values
49 .into_iter()
50 .map(|value| AttributeValue::from(value.as_ref()))
51 .collect::<Vec<_>>()
52 .into(),
53 )
54 }
55}
56
57#[derive(Clone, Debug, Eq, PartialEq)]
59pub struct SearchEntry {
60 pub dn: String,
62 pub attributes: Attributes,
64}
65
66impl From<rasn_ldap::SearchResultEntry> for SearchEntry {
67 fn from(raw: rasn_ldap::SearchResultEntry) -> Self {
68 SearchEntry {
69 dn: raw.object_name.0,
70 attributes: raw.attributes.into_iter().map(Into::into).collect(),
71 }
72 }
73}