pavex 0.2.10

A framework for building API services and web applications in Rust.
Documentation
use pavex_bp_schema::Blueprint as BlueprintSchema;

use super::reflection::{CreatedAt, Sources};

/// The input type for [`Blueprint::import`] and [`Blueprint::routes`].
///
/// A list of modules you want to import components from.
///
/// # Stability
///
/// [`Import`] is always populated by the [`from!`] macro.
/// Newer versions of Pavex may introduce, remove or modify the fields of this type—it is considered
/// an implementation detail of [`from!`] macros and should not be used directly.
///
/// Invoke the [`from!`] macro wherever an instance of [`Import`] is needed.
///
/// [`from!`]: super::from
/// [`Blueprint::import`]: crate::Blueprint::import
/// [`Blueprint::routes`]: crate::Blueprint::routes
pub struct Import {
    /// The modules you want to import components from.
    pub sources: Sources,
    #[doc(hidden)]
    /// The path of the module where this import was created (i.e. [`from!`] was invoked),
    /// obtained via [`std::module_path!`].
    ///
    /// It is used to resolve relative paths in the [`from!`] macro, i.e. paths starting
    /// with `super` or `self`.
    ///
    /// [`from!`]: super::from
    pub relative_to: &'static str,
    #[doc(hidden)]
    /// The location where this instance of [`Import`] was created, invoking the [`from!`] macro.
    ///
    /// [`from!`]: super::from
    pub created_at: CreatedAt,
}

/// The type returned by [`Blueprint::import`].
///
/// It allows you to further configure the behaviour of the registered import.
///
/// [`Blueprint::import`]: crate::Blueprint::import
pub struct RegisteredImport<'a> {
    #[allow(unused)]
    pub(crate) blueprint: &'a mut BlueprintSchema,
    /// The index of the registered import in the blueprint's `components` vector.
    #[allow(unused)]
    pub(crate) component_id: usize,
}