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
impl FieldName
Sourcepub fn app_unwrap(&self) -> &str
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");Sourcepub fn storage_name(&self) -> Option<&str>
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.
Sourcepub fn storage_name_unwrap(&self) -> &str
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.