Struct Config

Source
pub struct Config {
    pub environment: String,
    pub azure: AzureConfig,
    pub application: ApplicationConfig,
}
Expand description

Main application configuration structure.

Contains all configuration sections including Azure service settings and application-specific parameters.

Fields§

§environment: String

Environment name (e.g., “development”, “production”)

§azure: AzureConfig

Azure service configuration

§application: ApplicationConfig

Application-specific configuration

Implementations§

Source§

impl Config

Source

fn default_allowed_domains() -> Vec<String>

Default list of allowed domains for crawling.

Returns a curated list of documentation and reference sites that are commonly used for development and programming.

Source

pub fn from_env() -> Result<Self>

Creates a new configuration instance from environment variables.

Loads all required and optional configuration values from environment variables. Required variables will cause an error if not present, while optional variables have sensible defaults.

§Environment Variables
§Required
  • AZURE_SEARCH_SERVICE_NAME: Azure Cognitive Search service name
  • AZURE_SEARCH_API_KEY: Azure Cognitive Search API key
  • AZURE_COSMOS_ENDPOINT: CosmosDB account endpoint URL
  • AZURE_COSMOS_KEY: CosmosDB primary access key
§Optional (with defaults)
  • ENVIRONMENT: Environment name (default: “development”)
  • AZURE_SEARCH_API_VERSION: Search API version (default: “2023-11-01”)
  • AZURE_SEARCH_INDEX_NAME: Search index name (default: “web-pages”)
  • AZURE_COSMOS_DATABASE_NAME: Database name (default: “search-engine”)
  • AZURE_COSMOS_CONTAINER_NAME: Container name (default: “web-pages”)
  • MAX_CRAWL_DEPTH: Maximum crawl depth (default: 5)
  • CRAWL_DELAY_MS: Delay between requests (default: 1000)
  • MAX_CONCURRENT_REQUESTS: Concurrent requests (default: 10)
  • USER_AGENT: HTTP User-Agent (default: “SearchBot/1.0”)
  • ALLOWED_DOMAINS: Comma-separated domains (default: curated list)
  • PERIODIC_INDEX_INTERVAL_DAYS: Re-indexing interval (default: 7)
  • DUPLICATE_REMOVAL_INTERVAL_HOURS: Duplicate removal interval (default: 24)
  • ADMIN_API_KEY: API key for admin endpoints (default: “admin-key-change-me”)
§Returns

A configured Config instance ready for use.

§Errors

Returns an error if any required environment variable is missing or invalid.

Source

pub fn is_production(&self) -> bool

Checks if the application is running in production environment.

§Returns

true if the environment is set to “production”, false otherwise.

Source

pub fn is_development(&self) -> bool

Checks if the application is running in development environment.

§Returns

true if the environment is set to “development”, false otherwise.

Source

pub fn search_service_url(&self) -> String

Constructs the base URL for the Azure Cognitive Search service.

§Returns

The complete HTTPS URL for the search service.

Source

pub fn search_index_url(&self) -> String

Constructs the URL for the search index.

§Returns

The complete URL for managing the search index.

Source

pub fn search_documents_url(&self) -> String

Constructs the URL for search index documents operations.

§Returns

The complete URL for document operations (add, update, delete).

Source

pub fn search_query_url(&self) -> String

Constructs the URL for search query operations.

§Returns

The complete URL for performing search queries.

Source

pub fn is_domain_allowed(&self, domain: &str) -> bool

Checks if a domain is allowed for crawling.

§Arguments
  • domain - The domain name to check
§Returns

true if the domain is in the allowed domains list, false otherwise.

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Config

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Config

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Config

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Config

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Freeze for Config

§

impl RefUnwindSafe for Config

§

impl Send for Config

§

impl Sync for Config

§

impl Unpin for Config

§

impl UnwindSafe for Config

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromRef<T> for T
where T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,