<commit_before>use std::collections::{HashMap, HashSet};
use std::time::Duration;

use crate::controls::Control;
use crate::ldap::Ldap;
use crate::parse_filter;
use crate::protocol::LdapOp;
use crate::result::{LdapError, LdapResult, Result};

use tokio::sync::mpsc;
use tokio::time;

use lber::common::TagClass;
use lber::parse::parse_tag;
use lber::structure::{StructureTag, PL};
use lber::structures::{Boolean, Enumerated, Integer, OctetString, Sequence, Tag};
use lber::universal::Types;
use lber::IResult;

/// Possible values for search scope.
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum Scope {
    /// Base object; search only the object named in the base DN.
    Base = 0,
    /// Search the objects immediately below the base DN.
    OneLevel = 1,
    /// Search the object named in the base DN and the whole subtree below it.
    Subtree = 2,
}

/// Possible values for alias dereferencing during search.
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum DerefAliases {
    /// Never dereference.
    Never = 0,
    /// Dereference while retrieving objects according to search scope.
    Searching = 1,
    /// Dereference while finding the base object.
    Finding = 2,
    /// Always dereference.
    Always = 3,
}

#[derive(Debug)]
pub enum SearchItem {
    Entry(StructureTag),
    Referral(StructureTag),
    Done(LdapResult, Vec<Control>),
}

/// Wrapper for the internal structure of a result entry.
#[derive(Debug, Clone)]
pub struct ResultEntry(pub(crate) StructureTag);

impl ResultEntry {
    #[doc(hidden)]
    pub fn new(st: StructureTag) -> ResultEntry {
        ResultEntry(st)
    }

    pub fn is_ref(&self) -> bool {
        self.0.id == 19
    }

    pub fn is_intermediate(&self) -> bool {
        self.0.id == 25
    }
}

/// Additional parameters for the Search operation.
#[derive(Clone, Debug)]
pub struct SearchOptions {
    pub(crate) deref: DerefAliases,
    pub(crate) typesonly: bool,
    pub(crate) timelimit: i32,
    pub(crate) sizelimit: i32,
    pub(crate) autopage: Option<i32>,
}

impl SearchOptions {
    /// Create an instance of the structure with default values.
    pub fn new() -> Self {
        SearchOptions {
            deref: DerefAliases::Never,
            typesonly: false,
            timelimit: 0,
            sizelimit: 0,
            autopage: None,
        }
    }

    /// Set the method for dereferencing aliases.
    pub fn deref(mut self, d: DerefAliases) -> Self {
        self.deref = d;
        self
    }

    /// Set the indicator of returning just attribute names (`true`) vs. names and values (`false`).
    pub fn typesonly(mut self, typesonly: bool) -> Self {
        self.typesonly = typesonly;
        self
    }

    /// Set the time limit, in seconds, for the whole search operation.
    ///
    /// This is a server-side limit of the elapsed time for performing the operation, _not_ a
    /// network timeout for retrieving result entries or the result of the whole operation.
    pub fn timelimit(mut self, timelimit: i32) -> Self {
        self.timelimit = timelimit;
        self
    }

    /// Set the size limit, in entries, for the whole search operation.
    pub fn sizelimit(mut self, sizelimit: i32) -> Self {
        self.sizelimit = sizelimit;
        self
    }

    /// Set the page size for automatic PagedResults.
    ///
    /// If `pagesize` is greater than zero, use a PagedResults control with that
    /// page size for the next search request, and keep issuing requests until
    /// all results are returned, or an error or a timeout occur.
    ///
    /// Supplying another PagedResults control to the initial request is not allowed,
    /// and will generate an error. Other controls may be specified, and are replicated
    /// afresh in every subsequent search request. Care should be taken not to depend
    /// on response controls, because intermediate search results are not returned
    /// to the caller.
    ///
    /// Passing a `pagesize` less than or equal to zero will turn autopaging off.
    pub fn autopage(mut self, pagesize: i32) -> Self {
        self.autopage = Some(pagesize);
        self
    }
}
<commit_msg>Remove autopage setting<commit_after>use std::collections::{HashMap, HashSet};
use std::time::Duration;

use crate::controls::Control;
use crate::ldap::Ldap;
use crate::parse_filter;
use crate::protocol::LdapOp;
use crate::result::{LdapError, LdapResult, Result};

use tokio::sync::mpsc;
use tokio::time;

use lber::common::TagClass;
use lber::parse::parse_tag;
use lber::structure::{StructureTag, PL};
use lber::structures::{Boolean, Enumerated, Integer, OctetString, Sequence, Tag};
use lber::universal::Types;
use lber::IResult;

/// Possible values for search scope.
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum Scope {
    /// Base object; search only the object named in the base DN.
    Base = 0,
    /// Search the objects immediately below the base DN.
    OneLevel = 1,
    /// Search the object named in the base DN and the whole subtree below it.
    Subtree = 2,
}

/// Possible values for alias dereferencing during search.
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum DerefAliases {
    /// Never dereference.
    Never = 0,
    /// Dereference while retrieving objects according to search scope.
    Searching = 1,
    /// Dereference while finding the base object.
    Finding = 2,
    /// Always dereference.
    Always = 3,
}

#[derive(Debug)]
pub enum SearchItem {
    Entry(StructureTag),
    Referral(StructureTag),
    Done(LdapResult, Vec<Control>),
}

/// Wrapper for the internal structure of a result entry.
#[derive(Debug, Clone)]
pub struct ResultEntry(pub(crate) StructureTag);

impl ResultEntry {
    #[doc(hidden)]
    pub fn new(st: StructureTag) -> ResultEntry {
        ResultEntry(st)
    }

    pub fn is_ref(&self) -> bool {
        self.0.id == 19
    }

    pub fn is_intermediate(&self) -> bool {
        self.0.id == 25
    }
}

/// Additional parameters for the Search operation.
#[derive(Clone, Debug)]
pub struct SearchOptions {
    pub(crate) deref: DerefAliases,
    pub(crate) typesonly: bool,
    pub(crate) timelimit: i32,
    pub(crate) sizelimit: i32,
}

impl SearchOptions {
    /// Create an instance of the structure with default values.
    pub fn new() -> Self {
        SearchOptions {
            deref: DerefAliases::Never,
            typesonly: false,
            timelimit: 0,
            sizelimit: 0,
        }
    }

    /// Set the method for dereferencing aliases.
    pub fn deref(mut self, d: DerefAliases) -> Self {
        self.deref = d;
        self
    }

    /// Set the indicator of returning just attribute names (`true`) vs. names and values (`false`).
    pub fn typesonly(mut self, typesonly: bool) -> Self {
        self.typesonly = typesonly;
        self
    }

    /// Set the time limit, in seconds, for the whole search operation.
    ///
    /// This is a server-side limit of the elapsed time for performing the operation, _not_ a
    /// network timeout for retrieving result entries or the result of the whole operation.
    pub fn timelimit(mut self, timelimit: i32) -> Self {
        self.timelimit = timelimit;
        self
    }

    /// Set the size limit, in entries, for the whole search operation.
    pub fn sizelimit(mut self, sizelimit: i32) -> Self {
        self.sizelimit = sizelimit;
        self
    }
}

{'fraction_non_alphanumeric': 0.11052274270196877, 'fraction_numerical': 0.006788866259334691, 'mean_word_length': 2.7390862944162437, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5580251', 'n_tokens_mistral': 2257, 'n_tokens_neox': 2212, 'n_words': 784}