Struct psl::Datasource

source ·
pub struct Datasource {
Show 14 fields pub name: String, pub provider: String, pub active_provider: &'static str, pub url: StringFromEnvVar, pub url_span: Span, pub direct_url: Option<StringFromEnvVar>, pub direct_url_span: Option<Span>, pub documentation: Option<String>, pub active_connector: &'static dyn Connector, pub shadow_database_url: Option<(StringFromEnvVar, Span)>, pub relation_mode: Option<RelationMode>, pub namespaces: Vec<(String, Span)>, pub schemas_span: Option<Span>, pub connector_data: DatasourceConnectorData,
}
Expand description

a datasource from the prisma schema.

Fields§

§name: String§provider: String

The provider string

§active_provider: &'static str

The provider that was selected as active from all specified providers

§url: StringFromEnvVar§url_span: Span§direct_url: Option<StringFromEnvVar>§direct_url_span: Option<Span>§documentation: Option<String>§active_connector: &'static dyn Connector

the connector of the active provider

§shadow_database_url: Option<(StringFromEnvVar, Span)>

An optional user-defined shadow database URL.

§relation_mode: Option<RelationMode>

In which layer referential actions are handled.

§namespaces: Vec<(String, Span)>

Sorted vec of schemas defined in the schemas property.

§schemas_span: Option<Span>§connector_data: DatasourceConnectorData

Implementations§

source§

impl Datasource

source

pub fn downcast_connector_data<T>(&self) -> Option<&T>where T: 'static,

Extract connector-specific constructs. The type parameter must be the right one.

source

pub fn capabilities(&self) -> BitFlags<ConnectorCapability>

source

pub fn relation_mode(&self) -> RelationMode

The applicable relation mode for this datasource.

source

pub fn load_url<F>(&self, env: F) -> Result<String, Diagnostics>where F: Fn(&str) -> Option<String>,

Load the database URL, validating it and resolving env vars in the process. Also see load_url_with_config_dir().

source

pub fn load_url_no_validation<F>(&self, env: F) -> Result<String, Diagnostics>where F: Fn(&str) -> Option<String>,

Load the database URL, without validating it and resolve env vars in the process.

source

pub fn load_direct_url<F>(&self, env: F) -> Result<String, Diagnostics>where F: Fn(&str) -> Option<String>,

Load the direct database URL, validating it and resolving env vars in the process. If there is no directUrl passed, it will default to load_url().

source

pub fn load_url_with_config_dir<F>( &self, config_dir: &Path, env: F ) -> Result<String, Diagnostics>where F: Fn(&str) -> Option<String>,

Same as load_url(), with the following difference.

By default we treat relative paths (in the connection string and datasource url value) as relative to the CWD. This does not work in all cases, so we need a way to prefix these relative paths with a config_dir.

This is, at the time of this writing (2021-05-05), only used in the context of Node-API integration.

P.S. Don’t forget to add new parameters here if needed!

source

pub fn load_shadow_database_url(&self) -> Result<Option<String>, Diagnostics>

Load the shadow database URL, validating it and resolving env vars in the process.

source

pub fn provider_defined(&self) -> bool

source

pub fn url_defined(&self) -> bool

source

pub fn direct_url_defined(&self) -> bool

source

pub fn shadow_url_defined(&self) -> bool

source

pub fn relation_mode_defined(&self) -> bool

source

pub fn schemas_defined(&self) -> bool

Trait Implementations§

source§

impl Debug for Datasource

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.