Struct Environment

Source
pub struct Environment {
    pub project_path: PathBuf,
    pub project_dot_grafbase_path: PathBuf,
    pub project_grafbase_path: PathBuf,
    pub project_grafbase_schema_path: PathBuf,
    pub user_dot_grafbase_path: PathBuf,
    pub project_grafbase_registry_path: PathBuf,
    pub resolvers_source_path: PathBuf,
    pub resolvers_build_artifact_path: PathBuf,
    pub database_directory_path: PathBuf,
}
Expand description

a static representation of the current environment

must be initialized before use

Fields§

§project_path: PathBuf

the path of the (assumed) user project root ($PROJECT), the nearest ancestor directory with a grafbase/schema.graphql file

§project_dot_grafbase_path: PathBuf

the path of $PROJECT/.grafbase/, the Grafbase local developer tool cache and database directory, in the nearest ancestor directory with grafbase/schema.graphql

§project_grafbase_path: PathBuf

the path of $PROJECT/grafbase/, the Grafbase schema directory in the nearest ancestor directory with grafbase/schema.graphql

§project_grafbase_schema_path: PathBuf

the path of $PROJECT/grafbase/schema.graphql, the Grafbase schema, in the nearest ancestor directory with said directory and file

§user_dot_grafbase_path: PathBuf

the path of $HOME/.grafbase, the user level local developer tool cache directory

§project_grafbase_registry_path: PathBuf

the path of $PROJECT/.grafbase/registry.json, the registry derived from schema.graphql, in the nearest ancestor directory with a grabase/schema.graphql file

§resolvers_source_path: PathBuf

the path of the grafbase/resolvers directory.

§resolvers_build_artifact_path: PathBuf

the path within $PROJECT/.grafbase/ containing build artifacts for custom resolvers.

§database_directory_path: PathBuf

the path within ‘$PROJECT/.grafbase’ containing the database

Implementations§

Source§

impl Environment

Source

pub fn try_init() -> Result<(), CommonError>

initializes the static Environment instance

§Errors

returns CommonError::ReadCurrentDirectory if the current directory path cannot be read

returns CommonError::FindGrafbaseDirectory if the grafbase directory is not found

Source

pub fn get() -> &'static Self

returns a reference to the static Environment instance

§Panics

panics if the Environment object was not previously initialized using Environment::try_init()

Trait Implementations§

Source§

impl Debug for Environment

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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.

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.