pavex/blueprint/import.rs
1use pavex_bp_schema::Blueprint as BlueprintSchema;
2
3use super::reflection::{CreatedAt, Sources};
4
5/// The input type for [`Blueprint::import`] and [`Blueprint::routes`].
6///
7/// A list of modules you want to import components from.
8///
9/// # Stability
10///
11/// [`Import`] is always populated by the [`from!`] macro.
12/// Newer versions of Pavex may introduce, remove or modify the fields of this type—it is considered
13/// an implementation detail of [`from!`] macros and should not be used directly.
14///
15/// Invoke the [`from!`] macro wherever an instance of [`Import`] is needed.
16///
17/// [`from!`]: super::from
18/// [`Blueprint::import`]: crate::Blueprint::import
19/// [`Blueprint::routes`]: crate::Blueprint::routes
20pub struct Import {
21 /// The modules you want to import components from.
22 pub sources: Sources,
23 #[doc(hidden)]
24 /// The path of the module where this import was created (i.e. [`from!`] was invoked),
25 /// obtained via [`std::module_path!`].
26 ///
27 /// It is used to resolve relative paths in the [`from!`] macro, i.e. paths starting
28 /// with `super` or `self`.
29 ///
30 /// [`from!`]: super::from
31 pub relative_to: &'static str,
32 #[doc(hidden)]
33 /// The location where this instance of [`Import`] was created, invoking the [`from!`] macro.
34 ///
35 /// [`from!`]: super::from
36 pub created_at: CreatedAt,
37}
38
39/// The type returned by [`Blueprint::import`].
40///
41/// It allows you to further configure the behaviour of the registered import.
42///
43/// [`Blueprint::import`]: crate::Blueprint::import
44pub struct RegisteredImport<'a> {
45 #[allow(unused)]
46 pub(crate) blueprint: &'a mut BlueprintSchema,
47 /// The index of the registered import in the blueprint's `components` vector.
48 #[allow(unused)]
49 pub(crate) component_id: usize,
50}