Trait CrudOps

Source
pub trait CrudOps {
    // Required methods
    fn insert<'life0, 'async_trait, T>(
        &'life0 self,
        entity: T,
    ) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait>>
       where T: SqlQuery + SqlParams + Send + Sync + 'async_trait,
             Self: 'async_trait,
             'life0: 'async_trait;
    fn update<'life0, 'async_trait, T>(
        &'life0 self,
        entity: T,
    ) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait>>
       where T: SqlQuery + UpdateParams + Send + Sync + 'async_trait,
             Self: 'async_trait,
             'life0: 'async_trait;
    fn delete<'life0, 'async_trait, T>(
        &'life0 self,
        entity: T,
    ) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait>>
       where T: SqlQuery + SqlParams + Send + Sync + 'async_trait,
             Self: 'async_trait,
             'life0: 'async_trait;
    fn fetch<'life0, 'life1, 'async_trait, T>(
        &'life0 self,
        params: &'life1 T,
    ) -> Pin<Box<dyn Future<Output = Result<T, Error>> + Send + 'async_trait>>
       where T: SqlQuery + FromRow + SqlParams + Send + Sync + 'async_trait,
             Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn fetch_all<'life0, 'life1, 'async_trait, T>(
        &'life0 self,
        params: &'life1 T,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<T>, Error>> + Send + 'async_trait>>
       where T: SqlQuery + FromRow + SqlParams + Send + Sync + 'async_trait,
             Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn select<'life0, 'async_trait, T, R, F>(
        &'life0 self,
        entity: T,
        to_model: F,
    ) -> Pin<Box<dyn Future<Output = Result<R, Error>> + Send + 'async_trait>>
       where T: SqlQuery + SqlParams + Send + Sync + 'async_trait,
             F: FnOnce(&Row) -> Result<R, Error> + Send + Sync + 'async_trait,
             R: 'async_trait,
             Self: 'async_trait,
             'life0: 'async_trait;
    fn select_all<'life0, 'async_trait, T, R, F>(
        &'life0 self,
        entity: T,
        to_model: F,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<R>, Error>> + Send + 'async_trait>>
       where T: SqlQuery + SqlParams + Send + Sync + 'async_trait,
             F: Fn(&Row) -> R + Send + Sync + 'async_trait,
             R: 'async_trait,
             Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

CrudOps trait’i, Pool nesnesi için CRUD işlemlerini extension method olarak sağlar. Bu trait, Pool üzerinde doğrudan CRUD işlemlerini çağırmayı mümkün kılar.

Required Methods§

Source

fn insert<'life0, 'async_trait, T>( &'life0 self, entity: T, ) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait>>
where T: SqlQuery + SqlParams + Send + Sync + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Veritabanına yeni bir kayıt ekler.

§Parametreler
  • entity - Eklenecek veri nesnesi (SqlQuery ve SqlParams trait’lerini uygulamalıdır)
§Dönüş Değeri
  • Result<u64, Error> - Eklenen kayıt sayısı veya hata
Source

fn update<'life0, 'async_trait, T>( &'life0 self, entity: T, ) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait>>
where T: SqlQuery + UpdateParams + Send + Sync + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Veritabanındaki mevcut bir kaydı günceller.

§Parametreler
  • entity - Güncelleme bilgilerini içeren veri nesnesi (SqlQuery ve UpdateParams trait’lerini uygulamalıdır)
§Dönüş Değeri
  • Result<u64, Error> - Güncellenen kayıt sayısı veya hata
Source

fn delete<'life0, 'async_trait, T>( &'life0 self, entity: T, ) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait>>
where T: SqlQuery + SqlParams + Send + Sync + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Veritabanından bir kaydı siler.

§Parametreler
  • entity - Silinecek kaydın bilgilerini içeren veri nesnesi (SqlQuery ve SqlParams trait’lerini uygulamalıdır)
§Dönüş Değeri
  • Result<u64, Error> - Silinen kayıt sayısı veya hata
Source

fn fetch<'life0, 'life1, 'async_trait, T>( &'life0 self, params: &'life1 T, ) -> Pin<Box<dyn Future<Output = Result<T, Error>> + Send + 'async_trait>>
where T: SqlQuery + FromRow + SqlParams + Send + Sync + 'async_trait, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Belirtilen kriterlere uygun tek bir kaydı getirir.

§Parametreler
  • params - Sorgu parametreleri (SqlQuery, FromRow ve SqlParams trait’lerini uygulamalıdır)
§Dönüş Değeri
  • Result<T, Error> - Getirilen kayıt veya hata
Source

fn fetch_all<'life0, 'life1, 'async_trait, T>( &'life0 self, params: &'life1 T, ) -> Pin<Box<dyn Future<Output = Result<Vec<T>, Error>> + Send + 'async_trait>>
where T: SqlQuery + FromRow + SqlParams + Send + Sync + 'async_trait, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Belirtilen kriterlere uygun tüm kayıtları getirir.

§Parametreler
  • params - Sorgu parametreleri (SqlQuery, FromRow ve SqlParams trait’lerini uygulamalıdır)
§Dönüş Değeri
  • Result<Vec<T>, Error> - Getirilen kayıtlar veya hata
Source

fn select<'life0, 'async_trait, T, R, F>( &'life0 self, entity: T, to_model: F, ) -> Pin<Box<dyn Future<Output = Result<R, Error>> + Send + 'async_trait>>
where T: SqlQuery + SqlParams + Send + Sync + 'async_trait, F: FnOnce(&Row) -> Result<R, Error> + Send + Sync + 'async_trait, R: 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Belirtilen özel dönüşüm fonksiyonunu kullanarak tek bir kaydı getirir.

§Parametreler
  • entity - Sorgu parametreleri (SqlQuery ve SqlParams trait’lerini uygulamalıdır)
  • to_model - Row -> R dönüşümünü gerçekleştiren fonksiyon
§Dönüş Değeri
  • Result<R, Error> - Dönüştürülen kayıt veya hata
Source

fn select_all<'life0, 'async_trait, T, R, F>( &'life0 self, entity: T, to_model: F, ) -> Pin<Box<dyn Future<Output = Result<Vec<R>, Error>> + Send + 'async_trait>>
where T: SqlQuery + SqlParams + Send + Sync + 'async_trait, F: Fn(&Row) -> R + Send + Sync + 'async_trait, R: 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Belirtilen özel dönüşüm fonksiyonunu kullanarak tüm kayıtları getirir.

§Parametreler
  • entity - Sorgu parametreleri (SqlQuery ve SqlParams trait’lerini uygulamalıdır)
  • to_model - Row -> R dönüşümünü gerçekleştiren fonksiyon
§Dönüş Değeri
  • Result<Vec<R>, Error> - Dönüştürülen kayıtlar veya hata

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl CrudOps for Pool

Pool nesnesi için CrudOps trait’inin implementasyonu