Skip to main content

PlanBuilder

Struct PlanBuilder 

Source
pub struct PlanBuilder<S: Schema> { /* private fields */ }
Expand description

Builds one Plan. See the module documentation for the rules.

Methods never fail; the first invalid call is returned by Self::build.

Implementations§

Source§

impl<S: Schema> PlanBuilder<S>

Source

pub fn new() -> Self

An empty program.

Source

pub fn exact<M: ThingModel<Schema = S>>(&mut self) -> Thing<M, Exact>

Match things of exactly model M.

Source

pub fn subtypes<M: ThingModel<Schema = S>>(&mut self) -> Thing<M, Subtypes>

Match things of model M or any of its subtypes.

Source

pub fn field<M, Mode, Owner, V>( &mut self, thing: Thing<M, Mode>, token: FieldToken<Owner, V>, ) -> Value
where M: ThingModel<Schema = S> + NominalUpcast<Owner>, Mode: SelectionMode, Owner: Model<Schema = S>,

Bind the value of thing’s field. Things without the field do not match.

Source

pub fn input<V>(&mut self, name: &str) -> Input<V>
where V: QueryValued, V::Domain: PlanScalar,

Declare an input column named name; each Self::row supplies a value. Many rows run the one plan over all of them.

Source

pub fn optional_input<V>(&mut self, name: &str) -> Input<V>
where V: QueryValued, V::Domain: PlanScalar,

Declare an optional input column; rows may give it Input::absent.

Source

pub fn where_(&mut self, condition: Condition) -> &mut Self

Require condition of every matched row.

Require relation to link player in role.

Source

pub fn let_(&mut self, name: &str, expr: impl Into<Expr>) -> Value

Bind name to expr, evaluated for each matched row.

Source

pub fn update<M, Mode, Owner, V>( &mut self, thing: Thing<M, Mode>, token: FieldToken<Owner, V>, value: impl Into<Operand>, ) -> &mut Self
where M: ThingModel<Schema = S> + NominalUpcast<Owner>, Mode: SelectionMode, Owner: Model<Schema = S>,

Replace thing’s field value with value.

Source

pub fn update_player<R, RMode, Owner, Players, P, PMode>( &mut self, relation: Thing<R, RMode>, role: RoleToken<Owner, Players>, player: Thing<P, PMode>, ) -> &mut Self
where R: ThingModel<Schema = S> + RoleTokenCompatible<Owner, Players>, RMode: SelectionMode, Owner: RelationModel<Schema = S>, Players: RolePlayerBinding<P, PMode>, P: ThingModel<Schema = S>, PMode: SelectionMode,

Make player the role player of relation.

Source

pub fn insert<M: ThingModel<Schema = S>>(&mut self) -> NewThing<'_, S, M>

Create a thing of model M; give it fields and players on the returned NewThing.

Source

pub fn put<M: ThingModel<Schema = S>>(&mut self) -> NewThing<'_, S, M>

Match a thing of model M with the fields and players given on the returned NewThing, or create it.

Source

pub fn delete<M: ThingModel<Schema = S>, Mode: SelectionMode>( &mut self, thing: Thing<M, Mode>, ) -> &mut Self

Delete thing.

Source

pub fn delete_field<M, Mode, Owner, V>( &mut self, thing: Thing<M, Mode>, token: FieldToken<Owner, V>, ) -> &mut Self
where M: ThingModel<Schema = S> + NominalUpcast<Owner>, Mode: SelectionMode, Owner: Model<Schema = S>,

Delete thing’s field, keeping the thing.

Source

pub fn delete_player<R, RMode, Owner, Players, P, PMode>( &mut self, relation: Thing<R, RMode>, role: RoleToken<Owner, Players>, player: Thing<P, PMode>, ) -> &mut Self
where R: ThingModel<Schema = S> + RoleTokenCompatible<Owner, Players>, RMode: SelectionMode, Owner: RelationModel<Schema = S>, Players: RolePlayerBinding<P, PMode>, P: ThingModel<Schema = S>, PMode: SelectionMode,

Remove player from relation’s role.

Source

pub fn row(&mut self, values: impl IntoIterator<Item = InputValue>) -> &mut Self

Add one input row. Every column appears at most once; a missing optional column is absent.

Source

pub fn returning( &mut self, columns: impl IntoIterator<Item = impl Into<Column>>, ) -> &mut Self

Project columns, in order. A write plan then answers these rows from the same pipeline instead of its matched count.

Source

pub fn count(&mut self) -> &mut Self

Answer the number of rows a read plan matches.

Source

pub fn exists(&mut self) -> &mut Self

Answer whether a read plan matches any row.

Source

pub fn build(self, schema: &SchemaPackage<S>) -> Result<Plan<S>>

Validate the program against the generated schema package.

A plan with writes answers its matched row count, or the Self::returning rows. A read answers rows, or Self::count / Self::exists.

§Errors

Returns the first invalid builder call, a package without compiled schema authority, or the plan validation failure (for example a field the thing does not own, or a key field update).

Trait Implementations§

Source§

impl<S: Schema> Debug for PlanBuilder<S>

Source§

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

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

impl<S: Schema> Default for PlanBuilder<S>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<S> !RefUnwindSafe for PlanBuilder<S>

§

impl<S> !UnwindSafe for PlanBuilder<S>

§

impl<S> Freeze for PlanBuilder<S>
where PhantomData<fn() -> S>: Freeze,

§

impl<S> Send for PlanBuilder<S>
where PhantomData<fn() -> S>: Send,

§

impl<S> Sync for PlanBuilder<S>
where PhantomData<fn() -> S>: Sync,

§

impl<S> Unpin for PlanBuilder<S>
where PhantomData<fn() -> S>: Unpin,

§

impl<S> UnsafeUnpin for PlanBuilder<S>
where PhantomData<fn() -> S>: UnsafeUnpin,

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

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more