FieldName

Struct FieldName 

Source
pub struct FieldName {
    pub app: Option<String>,
    pub storage: Option<String>,
}
Expand description

The name of a field, with separate application and storage representations.

The app field is the Rust-facing name (e.g., user_name). It is Option<String> to support unnamed (tuple) fields in the future; for now it is always Some. The optional storage field overrides the column name used in the database; when None, app is used as the storage name.

§Examples

use toasty_core::schema::app::FieldName;

let name = FieldName {
    app: Some("user_name".to_string()),
    storage: Some("username".to_string()),
};
assert_eq!(name.storage_name(), Some("username"));

let default_name = FieldName {
    app: Some("email".to_string()),
    storage: None,
};
assert_eq!(default_name.storage_name(), Some("email"));

Fields§

§app: Option<String>

The application-level (Rust) name of the field. None for unnamed (tuple) fields.

§storage: Option<String>

Optional override for the database column name. When None, app is used.

Implementations§

Source§

impl FieldName

Source

pub fn app_unwrap(&self) -> &str

Returns the application-level (Rust) name of this field.

This is a convenience accessor that unwraps the app field, which is Option<String> to support unnamed (tuple) fields. Most fields have an application name, and this method provides direct access without manual unwrapping.

§Panics

Panics if app is None (i.e., the field is unnamed).

§Examples
use toasty_core::schema::app::FieldName;

let name = FieldName {
    app: Some("user_name".to_string()),
    storage: None,
};
assert_eq!(name.app_unwrap(), "user_name");
Source

pub fn storage_name(&self) -> Option<&str>

Returns the storage (database column) name for this field, if one can be determined.

Returns storage if set, otherwise falls back to app. Returns None only when both fields are None.

Source

pub fn storage_name_unwrap(&self) -> &str

Returns the storage (database column) name for this field.

This is a convenience wrapper around storage_name for callers that expect a name to always be present.

§Panics

Panics if both storage and app are None.

Trait Implementations§

Source§

impl Clone for FieldName

Source§

fn clone(&self) -> FieldName

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FieldName

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for FieldName

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.