use crate::{schema::ValidateCreate, stmt::Path};
#[diagnostic::on_unimplemented(
message = "this expression cannot be used as a Toasty create scope",
label = "this expression does not support scoped creation",
note = "Only direct relation scopes support scoped creation.",
note = "Multi-step (`via`) relation scopes can be queried and filtered, but Toasty cannot create records through them because that would require creating or choosing intermediate records."
)]
pub trait Scope {
type Item;
type Path<Origin>;
type Create;
fn new_path<Origin>(path: Path<Origin, Self::Item>) -> Self::Path<Origin>;
fn new_create() -> Self::Create;
fn new_path_root() -> Self::Path<Self::Item>;
}
#[doc(hidden)]
#[diagnostic::on_unimplemented(
message = "this scope does not support scoped creation",
label = "this relation scope cannot create records",
note = "Only direct relation scopes support scoped creation.",
note = "Multi-step (`via`) relation scopes can be queried and filtered, but Toasty cannot create records through them because that would require creating or choosing intermediate records."
)]
pub trait CreateScope: Scope + ValidateCreate {
fn create_in_scope(self) -> Self::Create;
}