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>
impl<S: Schema> PlanBuilder<S>
Sourcepub fn exact<M: ThingModel<Schema = S>>(&mut self) -> Thing<M, Exact>
pub fn exact<M: ThingModel<Schema = S>>(&mut self) -> Thing<M, Exact>
Match things of exactly model M.
Sourcepub fn subtypes<M: ThingModel<Schema = S>>(&mut self) -> Thing<M, Subtypes>
pub fn subtypes<M: ThingModel<Schema = S>>(&mut self) -> Thing<M, Subtypes>
Match things of model M or any of its subtypes.
Sourcepub fn field<M, Mode, Owner, V>(
&mut self,
thing: Thing<M, Mode>,
token: FieldToken<Owner, V>,
) -> Valuewhere
M: ThingModel<Schema = S> + NominalUpcast<Owner>,
Mode: SelectionMode,
Owner: Model<Schema = S>,
pub fn field<M, Mode, Owner, V>(
&mut self,
thing: Thing<M, Mode>,
token: FieldToken<Owner, V>,
) -> Valuewhere
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.
Sourcepub fn input<V>(&mut self, name: &str) -> Input<V>where
V: QueryValued,
V::Domain: PlanScalar,
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.
Sourcepub fn optional_input<V>(&mut self, name: &str) -> Input<V>where
V: QueryValued,
V::Domain: PlanScalar,
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.
Sourcepub fn where_(&mut self, condition: Condition) -> &mut Self
pub fn where_(&mut self, condition: Condition) -> &mut Self
Require condition of every matched row.
Sourcepub fn links<R, RMode, Owner, Players, P, PMode>(
&mut self,
relation: Thing<R, RMode>,
role: RoleToken<Owner, Players>,
player: Thing<P, PMode>,
) -> &mut Selfwhere
R: ThingModel<Schema = S> + RoleTokenCompatible<Owner, Players>,
RMode: SelectionMode,
Owner: RelationModel<Schema = S>,
Players: RolePlayerBinding<P, PMode>,
P: ThingModel<Schema = S>,
PMode: SelectionMode,
pub fn links<R, RMode, Owner, Players, P, PMode>(
&mut self,
relation: Thing<R, RMode>,
role: RoleToken<Owner, Players>,
player: Thing<P, PMode>,
) -> &mut Selfwhere
R: ThingModel<Schema = S> + RoleTokenCompatible<Owner, Players>,
RMode: SelectionMode,
Owner: RelationModel<Schema = S>,
Players: RolePlayerBinding<P, PMode>,
P: ThingModel<Schema = S>,
PMode: SelectionMode,
Require relation to link player in role.
Sourcepub fn let_(&mut self, name: &str, expr: impl Into<Expr>) -> Value
pub fn let_(&mut self, name: &str, expr: impl Into<Expr>) -> Value
Bind name to expr, evaluated for each matched row.
Sourcepub fn update<M, Mode, Owner, V>(
&mut self,
thing: Thing<M, Mode>,
token: FieldToken<Owner, V>,
value: impl Into<Operand>,
) -> &mut Selfwhere
M: ThingModel<Schema = S> + NominalUpcast<Owner>,
Mode: SelectionMode,
Owner: Model<Schema = S>,
pub fn update<M, Mode, Owner, V>(
&mut self,
thing: Thing<M, Mode>,
token: FieldToken<Owner, V>,
value: impl Into<Operand>,
) -> &mut Selfwhere
M: ThingModel<Schema = S> + NominalUpcast<Owner>,
Mode: SelectionMode,
Owner: Model<Schema = S>,
Replace thing’s field value with value.
Sourcepub fn update_player<R, RMode, Owner, Players, P, PMode>(
&mut self,
relation: Thing<R, RMode>,
role: RoleToken<Owner, Players>,
player: Thing<P, PMode>,
) -> &mut Selfwhere
R: ThingModel<Schema = S> + RoleTokenCompatible<Owner, Players>,
RMode: SelectionMode,
Owner: RelationModel<Schema = S>,
Players: RolePlayerBinding<P, PMode>,
P: ThingModel<Schema = S>,
PMode: SelectionMode,
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 Selfwhere
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.
Sourcepub fn insert<M: ThingModel<Schema = S>>(&mut self) -> NewThing<'_, S, M>
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.
Sourcepub fn put<M: ThingModel<Schema = S>>(&mut self) -> NewThing<'_, S, M>
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.
Sourcepub fn delete<M: ThingModel<Schema = S>, Mode: SelectionMode>(
&mut self,
thing: Thing<M, Mode>,
) -> &mut Self
pub fn delete<M: ThingModel<Schema = S>, Mode: SelectionMode>( &mut self, thing: Thing<M, Mode>, ) -> &mut Self
Delete thing.
Sourcepub fn delete_field<M, Mode, Owner, V>(
&mut self,
thing: Thing<M, Mode>,
token: FieldToken<Owner, V>,
) -> &mut Selfwhere
M: ThingModel<Schema = S> + NominalUpcast<Owner>,
Mode: SelectionMode,
Owner: Model<Schema = S>,
pub fn delete_field<M, Mode, Owner, V>(
&mut self,
thing: Thing<M, Mode>,
token: FieldToken<Owner, V>,
) -> &mut Selfwhere
M: ThingModel<Schema = S> + NominalUpcast<Owner>,
Mode: SelectionMode,
Owner: Model<Schema = S>,
Delete thing’s field, keeping the thing.
Sourcepub fn delete_player<R, RMode, Owner, Players, P, PMode>(
&mut self,
relation: Thing<R, RMode>,
role: RoleToken<Owner, Players>,
player: Thing<P, PMode>,
) -> &mut Selfwhere
R: ThingModel<Schema = S> + RoleTokenCompatible<Owner, Players>,
RMode: SelectionMode,
Owner: RelationModel<Schema = S>,
Players: RolePlayerBinding<P, PMode>,
P: ThingModel<Schema = S>,
PMode: SelectionMode,
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 Selfwhere
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.
Sourcepub fn row(&mut self, values: impl IntoIterator<Item = InputValue>) -> &mut Self
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.
Sourcepub fn returning(
&mut self,
columns: impl IntoIterator<Item = impl Into<Column>>,
) -> &mut Self
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.
Sourcepub fn build(self, schema: &SchemaPackage<S>) -> Result<Plan<S>>
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>
impl<S: Schema> Debug for PlanBuilder<S>
Auto Trait Implementations§
impl<S> !RefUnwindSafe for PlanBuilder<S>
impl<S> !UnwindSafe for PlanBuilder<S>
impl<S> Freeze for PlanBuilder<S>
impl<S> Send for PlanBuilder<S>
impl<S> Sync for PlanBuilder<S>
impl<S> Unpin for PlanBuilder<S>
impl<S> UnsafeUnpin for PlanBuilder<S>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request