Struct butane::ForeignKey[][src]

pub struct ForeignKey<T> where
    T: DataObject
{ /* fields omitted */ }
Expand description

Used to implement a relationship between models.

Initialize using From or from_pk

Examples

#[model]
struct Blog {
  ...
}
#[model]
struct Post {
  blog: ForeignKey<Blog>,
  ...
}

Implementations

Returns a reference to the value. It must have already been loaded. If not, returns Error::ValueNotLoaded

Returns a reference to the primary key of the value.

Loads the value referred to by this foreign key from the database if necessary and returns a reference to it.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

Reference type. Used for ergonomics with String (which has reference type str). For most, it is Self Read more

Performs the conversion.

Performs the conversion.

Used to convert a SqlValRef into another type.

Used to convert a SqlVal into another type. The default implementation calls Self::from_sql_ref(val.as_ref()), which may be inefficient. This method is chiefly used only for primary keys: a more efficient implementation is unlikely to provide benefits for types not used as primary keys. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Serialize this value into the given Serde serializer. Read more

The default implementation simply calls to_sql. Provide an alternative implementation if greater efficiency can be realized by consuming self. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Performs the conversion.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.