pub struct Layer {
pub map_id: i32,
pub type_: LayerType,
pub name: String,
pub is_alternative: bool,
pub id: Uuid,
pub marked_deleted: Option<NaiveDateTime>,
pub order_index: i32,
}
Expand description
The Layer
entity.
Fields§
§map_id: i32
The id of the map this layer belongs to.
type_: LayerType
The type of layer.
name: String
The name of the layer.
is_alternative: bool
A flag indicating if this layer is an user created alternative.
id: Uuid
The id of the layer.
marked_deleted: Option<NaiveDateTime>
Set if the layer has been soft-deleted
order_index: i32
Order within the map.
Implementations§
source§impl Layer
impl Layer
sourcepub async fn find(
search_parameters: LayerSearchParameters,
conn: &mut AsyncPgConnection,
) -> QueryResult<Vec<LayerDto>>
pub async fn find( search_parameters: LayerSearchParameters, conn: &mut AsyncPgConnection, ) -> QueryResult<Vec<LayerDto>>
Get a page of layers.
Can be filtered by its active status if one is provided in search_parameters
.
§Errors
- Unknown, diesel doesn’t say why it might error.
sourcepub async fn find_by_id(
id: Uuid,
conn: &mut AsyncPgConnection,
) -> QueryResult<Self>
pub async fn find_by_id( id: Uuid, conn: &mut AsyncPgConnection, ) -> QueryResult<Self>
sourceasync fn defer_unique_order_index_constraint(
transaction: &mut AsyncPgConnection,
) -> QueryResult<()>
async fn defer_unique_order_index_constraint( transaction: &mut AsyncPgConnection, ) -> QueryResult<()>
Defer checking of the unique constraint (map_id
, order_index
, marked_deleted
)
until the end of the current transaction.
§Errors
- Unknown, diesel doesn’t say why it might error.
sourceasync fn shift_order_indices_by(
map_id: i32,
order_index: i32,
increment: bool,
transaction: &mut AsyncPgConnection,
) -> QueryResult<()>
async fn shift_order_indices_by( map_id: i32, order_index: i32, increment: bool, transaction: &mut AsyncPgConnection, ) -> QueryResult<()>
Helper to increment or decrement all layers with order_index
greater or equal the provided index. This is used when layers get
deleted/restored to shift all subsequent layers up/down one place.
§Errors
- Unknown, diesel doesn’t say why it might error.
sourcepub async fn create(
map_id: i32,
new_layer: LayerDto,
conn: &mut AsyncPgConnection,
) -> QueryResult<LayerDto>
pub async fn create( map_id: i32, new_layer: LayerDto, conn: &mut AsyncPgConnection, ) -> QueryResult<LayerDto>
sourcepub async fn reorder(
new_order: Vec<Uuid>,
conn: &mut AsyncPgConnection,
) -> QueryResult<()>
pub async fn reorder( new_order: Vec<Uuid>, conn: &mut AsyncPgConnection, ) -> QueryResult<()>
Reorder multiple layers in the database. That means
setting all order_index
fields.
§Errors
- Unknown, diesel doesn’t say why it might error.
sourcefn do_order_update(
updates: Vec<UpdateLayerOrderIndex>,
conn: &mut AsyncPgConnection,
) -> Vec<impl Future<Output = QueryResult<usize>>>
fn do_order_update( updates: Vec<UpdateLayerOrderIndex>, conn: &mut AsyncPgConnection, ) -> Vec<impl Future<Output = QueryResult<usize>>>
This helper function is needed, with explicit type annotations.
sourcepub async fn rename(
dto: LayerRenameDto,
conn: &mut AsyncPgConnection,
) -> QueryResult<()>
pub async fn rename( dto: LayerRenameDto, conn: &mut AsyncPgConnection, ) -> QueryResult<()>
sourceasync fn set_marked_deleted(
drawing_layer_id: Uuid,
marked_deleted: bool,
conn: &mut AsyncPgConnection,
) -> QueryResult<Self>
async fn set_marked_deleted( drawing_layer_id: Uuid, marked_deleted: bool, conn: &mut AsyncPgConnection, ) -> QueryResult<Self>
Soft-delete or restoring layers in the database by settings the marked_deleted
field.
§Errors
- Unknown, diesel doesn’t say why it might error.
sourcepub async fn delete(
map_id: i32,
layer_id: Uuid,
conn: &mut AsyncPgConnection,
) -> QueryResult<()>
pub async fn delete( map_id: i32, layer_id: Uuid, conn: &mut AsyncPgConnection, ) -> QueryResult<()>
Soft-delete a layers in the database by settings the marked_deleted
field to the current date.
All subsequent layers are moved one order_index
down.
§Errors
- Unknown, diesel doesn’t say why it might error.
sourcepub async fn restore(
map_id: i32,
layer_id: Uuid,
conn: &mut AsyncPgConnection,
) -> QueryResult<()>
pub async fn restore( map_id: i32, layer_id: Uuid, conn: &mut AsyncPgConnection, ) -> QueryResult<()>
Restore a layers that has been marked deleted in the database.
The layer takes on its previous order_index
and all subsequent
layers are moved one layer down.
§Errors
- Unknown, diesel doesn’t say why it might error.
Trait Implementations§
source§impl<'ident> Identifiable for &'ident Layer
impl<'ident> Identifiable for &'ident Layer
source§impl<'insert> Insertable<table> for &'insert Layer
impl<'insert> Insertable<table> for &'insert Layer
§type Values = <(Option<Grouped<Eq<map_id, <&'insert i32 as AsExpression<<map_id as Expression>::SqlType>>::Expression>>>, Option<Grouped<Eq<type_, <&'insert LayerType as AsExpression<<type_ as Expression>::SqlType>>::Expression>>>, Option<Grouped<Eq<name, <&'insert String as AsExpression<<name as Expression>::SqlType>>::Expression>>>, Option<Grouped<Eq<is_alternative, <&'insert bool as AsExpression<<is_alternative as Expression>::SqlType>>::Expression>>>, Option<Grouped<Eq<id, <&'insert Uuid as AsExpression<<id as Expression>::SqlType>>::Expression>>>, Option<Grouped<Eq<marked_deleted, <&'insert NaiveDateTime as AsExpression<<marked_deleted as Expression>::SqlType>>::Expression>>>, Option<Grouped<Eq<order_index, <&'insert i32 as AsExpression<<order_index as Expression>::SqlType>>::Expression>>>) as Insertable<table>>::Values
type Values = <(Option<Grouped<Eq<map_id, <&'insert i32 as AsExpression<<map_id as Expression>::SqlType>>::Expression>>>, Option<Grouped<Eq<type_, <&'insert LayerType as AsExpression<<type_ as Expression>::SqlType>>::Expression>>>, Option<Grouped<Eq<name, <&'insert String as AsExpression<<name as Expression>::SqlType>>::Expression>>>, Option<Grouped<Eq<is_alternative, <&'insert bool as AsExpression<<is_alternative as Expression>::SqlType>>::Expression>>>, Option<Grouped<Eq<id, <&'insert Uuid as AsExpression<<id as Expression>::SqlType>>::Expression>>>, Option<Grouped<Eq<marked_deleted, <&'insert NaiveDateTime as AsExpression<<marked_deleted as Expression>::SqlType>>::Expression>>>, Option<Grouped<Eq<order_index, <&'insert i32 as AsExpression<<order_index as Expression>::SqlType>>::Expression>>>) as Insertable<table>>::Values
VALUES
clause to insert these records Read moresource§fn values(
self,
) -> <(Option<Eq<map_id, &'insert i32>>, Option<Eq<type_, &'insert LayerType>>, Option<Eq<name, &'insert String>>, Option<Eq<is_alternative, &'insert bool>>, Option<Eq<id, &'insert Uuid>>, Option<Eq<marked_deleted, &'insert NaiveDateTime>>, Option<Eq<order_index, &'insert i32>>) as Insertable<table>>::Values
fn values( self, ) -> <(Option<Eq<map_id, &'insert i32>>, Option<Eq<type_, &'insert LayerType>>, Option<Eq<name, &'insert String>>, Option<Eq<is_alternative, &'insert bool>>, Option<Eq<id, &'insert Uuid>>, Option<Eq<marked_deleted, &'insert NaiveDateTime>>, Option<Eq<order_index, &'insert i32>>) as Insertable<table>>::Values
Self::Values
Read moresource§fn insert_into(self, table: T) -> InsertStatement<T, Self::Values>
fn insert_into(self, table: T) -> InsertStatement<T, Self::Values>
self
into a given table. Read moresource§impl Insertable<table> for Layer
impl Insertable<table> for Layer
§type Values = <(Option<Grouped<Eq<map_id, <i32 as AsExpression<<map_id as Expression>::SqlType>>::Expression>>>, Option<Grouped<Eq<type_, <LayerType as AsExpression<<type_ as Expression>::SqlType>>::Expression>>>, Option<Grouped<Eq<name, <String as AsExpression<<name as Expression>::SqlType>>::Expression>>>, Option<Grouped<Eq<is_alternative, <bool as AsExpression<<is_alternative as Expression>::SqlType>>::Expression>>>, Option<Grouped<Eq<id, <Uuid as AsExpression<<id as Expression>::SqlType>>::Expression>>>, Option<Grouped<Eq<marked_deleted, <NaiveDateTime as AsExpression<<marked_deleted as Expression>::SqlType>>::Expression>>>, Option<Grouped<Eq<order_index, <i32 as AsExpression<<order_index as Expression>::SqlType>>::Expression>>>) as Insertable<table>>::Values
type Values = <(Option<Grouped<Eq<map_id, <i32 as AsExpression<<map_id as Expression>::SqlType>>::Expression>>>, Option<Grouped<Eq<type_, <LayerType as AsExpression<<type_ as Expression>::SqlType>>::Expression>>>, Option<Grouped<Eq<name, <String as AsExpression<<name as Expression>::SqlType>>::Expression>>>, Option<Grouped<Eq<is_alternative, <bool as AsExpression<<is_alternative as Expression>::SqlType>>::Expression>>>, Option<Grouped<Eq<id, <Uuid as AsExpression<<id as Expression>::SqlType>>::Expression>>>, Option<Grouped<Eq<marked_deleted, <NaiveDateTime as AsExpression<<marked_deleted as Expression>::SqlType>>::Expression>>>, Option<Grouped<Eq<order_index, <i32 as AsExpression<<order_index as Expression>::SqlType>>::Expression>>>) as Insertable<table>>::Values
VALUES
clause to insert these records Read moresource§fn values(
self,
) -> <(Option<Eq<map_id, i32>>, Option<Eq<type_, LayerType>>, Option<Eq<name, String>>, Option<Eq<is_alternative, bool>>, Option<Eq<id, Uuid>>, Option<Eq<marked_deleted, NaiveDateTime>>, Option<Eq<order_index, i32>>) as Insertable<table>>::Values
fn values( self, ) -> <(Option<Eq<map_id, i32>>, Option<Eq<type_, LayerType>>, Option<Eq<name, String>>, Option<Eq<is_alternative, bool>>, Option<Eq<id, Uuid>>, Option<Eq<marked_deleted, NaiveDateTime>>, Option<Eq<order_index, i32>>) as Insertable<table>>::Values
Self::Values
Read moresource§fn insert_into(self, table: T) -> InsertStatement<T, Self::Values>
fn insert_into(self, table: T) -> InsertStatement<T, Self::Values>
self
into a given table. Read moresource§impl<__DB: Backend, __ST0, __ST1, __ST2, __ST3, __ST4, __ST5, __ST6> Queryable<(__ST0, __ST1, __ST2, __ST3, __ST4, __ST5, __ST6), __DB> for Layerwhere
(i32, LayerType, String, bool, Uuid, Option<NaiveDateTime>, i32): FromStaticSqlRow<(__ST0, __ST1, __ST2, __ST3, __ST4, __ST5, __ST6), __DB>,
impl<__DB: Backend, __ST0, __ST1, __ST2, __ST3, __ST4, __ST5, __ST6> Queryable<(__ST0, __ST1, __ST2, __ST3, __ST4, __ST5, __ST6), __DB> for Layerwhere
(i32, LayerType, String, bool, Uuid, Option<NaiveDateTime>, i32): FromStaticSqlRow<(__ST0, __ST1, __ST2, __ST3, __ST4, __ST5, __ST6), __DB>,
impl UndecoratedInsertRecord<table> for Layer
Auto Trait Implementations§
impl Freeze for Layer
impl RefUnwindSafe for Layer
impl Send for Layer
impl Sync for Layer
impl Unpin for Layer
impl UnwindSafe for Layer
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> IntoSql for T
impl<T> IntoSql for T
source§fn into_sql<T>(self) -> Self::Expression
fn into_sql<T>(self) -> Self::Expression
self
to an expression for Diesel’s query builder. Read moresource§fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
&self
to an expression for Diesel’s query builder. Read moresource§impl<T, Conn> RunQueryDsl<Conn> for T
impl<T, Conn> RunQueryDsl<Conn> for T
source§fn execute<'conn, 'query>(
self,
conn: &'conn mut Conn,
) -> <Conn as AsyncConnection>::ExecuteFuture<'conn, 'query>
fn execute<'conn, 'query>( self, conn: &'conn mut Conn, ) -> <Conn as AsyncConnection>::ExecuteFuture<'conn, 'query>
source§fn load<'query, 'conn, U>(
self,
conn: &'conn mut Conn,
) -> AndThen<Self::LoadFuture<'conn>, TryCollect<Self::Stream<'conn>, Vec<U>>, fn(_: Self::Stream<'conn>) -> TryCollect<Self::Stream<'conn>, Vec<U>>>
fn load<'query, 'conn, U>( self, conn: &'conn mut Conn, ) -> AndThen<Self::LoadFuture<'conn>, TryCollect<Self::Stream<'conn>, Vec<U>>, fn(_: Self::Stream<'conn>) -> TryCollect<Self::Stream<'conn>, Vec<U>>>
source§fn load_stream<'conn, 'query, U>(
self,
conn: &'conn mut Conn,
) -> Self::LoadFuture<'conn>where
Conn: AsyncConnection,
U: 'conn,
Self: LoadQuery<'query, Conn, U> + 'query,
fn load_stream<'conn, 'query, U>(
self,
conn: &'conn mut Conn,
) -> Self::LoadFuture<'conn>where
Conn: AsyncConnection,
U: 'conn,
Self: LoadQuery<'query, Conn, U> + 'query,
source§fn get_result<'query, 'conn, U>(
self,
conn: &'conn mut Conn,
) -> AndThen<Self::LoadFuture<'conn>, Map<StreamFuture<Pin<Box<Self::Stream<'conn>>>>, fn(_: (Option<Result<U, Error>>, Pin<Box<Self::Stream<'conn>>>)) -> Result<U, Error>>, fn(_: Self::Stream<'conn>) -> Map<StreamFuture<Pin<Box<Self::Stream<'conn>>>>, fn(_: (Option<Result<U, Error>>, Pin<Box<Self::Stream<'conn>>>)) -> Result<U, Error>>>
fn get_result<'query, 'conn, U>( self, conn: &'conn mut Conn, ) -> AndThen<Self::LoadFuture<'conn>, Map<StreamFuture<Pin<Box<Self::Stream<'conn>>>>, fn(_: (Option<Result<U, Error>>, Pin<Box<Self::Stream<'conn>>>)) -> Result<U, Error>>, fn(_: Self::Stream<'conn>) -> Map<StreamFuture<Pin<Box<Self::Stream<'conn>>>>, fn(_: (Option<Result<U, Error>>, Pin<Box<Self::Stream<'conn>>>)) -> Result<U, Error>>>
source§fn get_results<'query, 'conn, U>(
self,
conn: &'conn mut Conn,
) -> AndThen<Self::LoadFuture<'conn>, TryCollect<Self::Stream<'conn>, Vec<U>>, fn(_: Self::Stream<'conn>) -> TryCollect<Self::Stream<'conn>, Vec<U>>>
fn get_results<'query, 'conn, U>( self, conn: &'conn mut Conn, ) -> AndThen<Self::LoadFuture<'conn>, TryCollect<Self::Stream<'conn>, Vec<U>>, fn(_: Self::Stream<'conn>) -> TryCollect<Self::Stream<'conn>, Vec<U>>>
Vec
with the affected rows. Read more