pub trait FieldAccess: Sized + Send + 'static {
    type Field: Field;
    type Path: Path;

    // Provided methods
    fn equals<'rhs, Rhs: 'rhs, Any>(
        self,
        rhs: Rhs
    ) -> <<Self::Field as Field>::Type as FieldEq<'rhs, Rhs, Any>>::EqCond<Self>
       where <Self::Field as Field>::Type: FieldEq<'rhs, Rhs, Any> { ... }
    fn not_equals<'rhs, Rhs: 'rhs, Any>(
        self,
        rhs: Rhs
    ) -> <<Self::Field as Field>::Type as FieldEq<'rhs, Rhs, Any>>::NeCond<Self>
       where <Self::Field as Field>::Type: FieldEq<'rhs, Rhs, Any> { ... }
    fn less_than<'rhs, Rhs: 'rhs, Any>(
        self,
        rhs: Rhs
    ) -> <<Self::Field as Field>::Type as FieldOrd<'rhs, Rhs, Any>>::LtCond<Self>
       where <Self::Field as Field>::Type: FieldOrd<'rhs, Rhs, Any> { ... }
    fn less_equals<'rhs, Rhs: 'rhs, Any>(
        self,
        rhs: Rhs
    ) -> <<Self::Field as Field>::Type as FieldOrd<'rhs, Rhs, Any>>::LeCond<Self>
       where <Self::Field as Field>::Type: FieldOrd<'rhs, Rhs, Any> { ... }
    fn greater_than<'rhs, Rhs: 'rhs, Any>(
        self,
        rhs: Rhs
    ) -> <<Self::Field as Field>::Type as FieldOrd<'rhs, Rhs, Any>>::GtCond<Self>
       where <Self::Field as Field>::Type: FieldOrd<'rhs, Rhs, Any> { ... }
    fn greater_equals<'rhs, Rhs: 'rhs, Any>(
        self,
        rhs: Rhs
    ) -> <<Self::Field as Field>::Type as FieldOrd<'rhs, Rhs, Any>>::GeCond<Self>
       where <Self::Field as Field>::Type: FieldOrd<'rhs, Rhs, Any> { ... }
    fn like<'rhs, Rhs: 'rhs, Any>(
        self,
        rhs: Rhs
    ) -> <<Self::Field as Field>::Type as FieldLike<'rhs, Rhs, Any>>::LiCond<Self>
       where <Self::Field as Field>::Type: FieldLike<'rhs, Rhs, Any> { ... }
    fn not_like<'rhs, Rhs: 'rhs, Any>(
        self,
        rhs: Rhs
    ) -> <<Self::Field as Field>::Type as FieldLike<'rhs, Rhs, Any>>::NlCond<Self>
       where <Self::Field as Field>::Type: FieldLike<'rhs, Rhs, Any> { ... }
    fn regexp<'rhs, Rhs: 'rhs, Any>(
        self,
        rhs: Rhs
    ) -> <<Self::Field as Field>::Type as FieldRegexp<'rhs, Rhs, Any>>::ReCond<Self>
       where <Self::Field as Field>::Type: FieldRegexp<'rhs, Rhs, Any> { ... }
    fn not_regexp<'rhs, Rhs: 'rhs, Any>(
        self,
        rhs: Rhs
    ) -> <<Self::Field as Field>::Type as FieldRegexp<'rhs, Rhs, Any>>::NrCond<Self>
       where <Self::Field as Field>::Type: FieldRegexp<'rhs, Rhs, Any> { ... }
}
Expand description

Trait only implemented by FieldProxy to reduce the amount of generics when using them.

Why


// function using FieldProxy
fn do_something<F, P>(proxy: FieldProxy<F, P>) {/* ... */}

// but in order to do useful things with the proxy, you will need bounds:
fn do_useful<F: Field, P: Path>(proxy: FieldProxy<F, P>) {/* ... */}

// function using FieldAccess
fn do_something_else<A: FieldAccess>(proxy: A) {/* ... */}

// the above already covers the useful part, but depending on your usage you could also use the `impl` sugar:
fn do_sugared(proxy: impl FieldAccess) {/* ... */}

Comparison operations

This trait also adds methods for comparing fields which just wrap their underlying comparison traits.

use rorm::Model;
use rorm::internal::field::access::FieldAccess;

#[derive(Model)]
struct User {
    #[rorm(id)]
    id: i64,

    #[rorm(max_length = 255)]
    name: String,
}

// Uses the `FieldEq` impl of `String`
let condition = User::F.name.equals("Bob".to_string());

Required Associated Types§

source

type Field: Field

Field which is accessed

Corresponds to the proxy’s F parameter

source

type Path: Path

Path the field is accessed through

Corresponds to the proxy’s P parameter

Provided Methods§

source

fn equals<'rhs, Rhs: 'rhs, Any>( self, rhs: Rhs ) -> <<Self::Field as Field>::Type as FieldEq<'rhs, Rhs, Any>>::EqCond<Self>
where <Self::Field as Field>::Type: FieldEq<'rhs, Rhs, Any>,

Compare the field to another value using ==

source

fn not_equals<'rhs, Rhs: 'rhs, Any>( self, rhs: Rhs ) -> <<Self::Field as Field>::Type as FieldEq<'rhs, Rhs, Any>>::NeCond<Self>
where <Self::Field as Field>::Type: FieldEq<'rhs, Rhs, Any>,

Compare the field to another value using !=

source

fn less_than<'rhs, Rhs: 'rhs, Any>( self, rhs: Rhs ) -> <<Self::Field as Field>::Type as FieldOrd<'rhs, Rhs, Any>>::LtCond<Self>
where <Self::Field as Field>::Type: FieldOrd<'rhs, Rhs, Any>,

Compare the field to another value using <

source

fn less_equals<'rhs, Rhs: 'rhs, Any>( self, rhs: Rhs ) -> <<Self::Field as Field>::Type as FieldOrd<'rhs, Rhs, Any>>::LeCond<Self>
where <Self::Field as Field>::Type: FieldOrd<'rhs, Rhs, Any>,

Compare the field to another value using <=

source

fn greater_than<'rhs, Rhs: 'rhs, Any>( self, rhs: Rhs ) -> <<Self::Field as Field>::Type as FieldOrd<'rhs, Rhs, Any>>::GtCond<Self>
where <Self::Field as Field>::Type: FieldOrd<'rhs, Rhs, Any>,

Compare the field to another value using <

source

fn greater_equals<'rhs, Rhs: 'rhs, Any>( self, rhs: Rhs ) -> <<Self::Field as Field>::Type as FieldOrd<'rhs, Rhs, Any>>::GeCond<Self>
where <Self::Field as Field>::Type: FieldOrd<'rhs, Rhs, Any>,

Compare the field to another value using >=

source

fn like<'rhs, Rhs: 'rhs, Any>( self, rhs: Rhs ) -> <<Self::Field as Field>::Type as FieldLike<'rhs, Rhs, Any>>::LiCond<Self>
where <Self::Field as Field>::Type: FieldLike<'rhs, Rhs, Any>,

Compare the field to another value using LIKE

source

fn not_like<'rhs, Rhs: 'rhs, Any>( self, rhs: Rhs ) -> <<Self::Field as Field>::Type as FieldLike<'rhs, Rhs, Any>>::NlCond<Self>
where <Self::Field as Field>::Type: FieldLike<'rhs, Rhs, Any>,

Compare the field to another value using NOT LIKE

source

fn regexp<'rhs, Rhs: 'rhs, Any>( self, rhs: Rhs ) -> <<Self::Field as Field>::Type as FieldRegexp<'rhs, Rhs, Any>>::ReCond<Self>
where <Self::Field as Field>::Type: FieldRegexp<'rhs, Rhs, Any>,

Compare the field to another value using >=

source

fn not_regexp<'rhs, Rhs: 'rhs, Any>( self, rhs: Rhs ) -> <<Self::Field as Field>::Type as FieldRegexp<'rhs, Rhs, Any>>::NrCond<Self>
where <Self::Field as Field>::Type: FieldRegexp<'rhs, Rhs, Any>,

Compare the field to another value using >=

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<F: Field, P: Path> FieldAccess for FieldProxy<F, P>

§

type Field = F

§

type Path = P