pub struct SchemaAst {
    pub tops: Vec<Top>,
}
Expand description

AST representation of a prisma schema.

This module is used internally to represent an AST. The AST’s nodes can be used during validation of a schema, especially when implementing custom attributes.

The AST is not validated, also fields and attributes are not resolved. Every node is annotated with its location in the text representation. Basically, the AST is an object oriented representation of the datamodel’s text. Schema = Datamodel + Generators + Datasources

Fields§

§tops: Vec<Top>

All models, enums, composite types, datasources, generators and type aliases.

Implementations§

source§

impl SchemaAst

source

pub fn find_at_position(&self, position: usize) -> SchemaPosition<'_>

Find the AST node at the given position (byte offset).

source

pub fn find_top_at_position(&self, position: usize) -> Option<TopId>

Do a binary search for the Top at the given byte offset.

source§

impl SchemaAst

source

pub fn iter_tops(&self) -> impl Iterator<Item = (TopId, &Top)>

Iterate over all the top-level items in the schema.

source

pub fn sources(&self) -> impl Iterator<Item = &SourceConfig>

Iterate over all the datasource blocks in the schema.

source

pub fn generators(&self) -> impl Iterator<Item = &GeneratorConfig>

Iterate over all the generator blocks in the schema.

Trait Implementations§

source§

impl Debug for SchemaAst

source§

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

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

impl Index<AttributeContainer> for SchemaAst

§

type Output = [Attribute]

The returned type after indexing.
source§

fn index( &self, index: AttributeContainer ) -> &<SchemaAst as Index<AttributeContainer>>::Output

Performs the indexing (container[index]) operation. Read more
source§

impl Index<AttributeId> for SchemaAst

§

type Output = Attribute

The returned type after indexing.
source§

fn index( &self, index: AttributeId ) -> &<SchemaAst as Index<AttributeId>>::Output

Performs the indexing (container[index]) operation. Read more
source§

impl Index<CompositeTypeId> for SchemaAst

§

type Output = CompositeType

The returned type after indexing.
source§

fn index( &self, index: CompositeTypeId ) -> &<SchemaAst as Index<CompositeTypeId>>::Output

Performs the indexing (container[index]) operation. Read more
source§

impl Index<EnumId> for SchemaAst

§

type Output = Enum

The returned type after indexing.
source§

fn index(&self, index: EnumId) -> &<SchemaAst as Index<EnumId>>::Output

Performs the indexing (container[index]) operation. Read more
source§

impl Index<ModelId> for SchemaAst

§

type Output = Model

The returned type after indexing.
source§

fn index(&self, index: ModelId) -> &<SchemaAst as Index<ModelId>>::Output

Performs the indexing (container[index]) operation. Read more
source§

impl Index<SourceId> for SchemaAst

§

type Output = SourceConfig

The returned type after indexing.
source§

fn index(&self, index: SourceId) -> &<SchemaAst as Index<SourceId>>::Output

Performs the indexing (container[index]) operation. Read more
source§

impl Index<TopId> for SchemaAst

§

type Output = Top

The returned type after indexing.
source§

fn index(&self, index: TopId) -> &<SchemaAst as Index<TopId>>::Output

Performs the indexing (container[index]) operation. 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.