pub struct Attribute {
pub name: String,
pub ty: AttrType,
pub default: Option<Value>,
}Expand description
A named, typed field of a resource.
Fields§
§name: StringThe attribute name.
ty: AttrTypeIts type.
default: Option<Value>A default applied on create when the value is absent.
Implementations§
Source§impl Attribute
impl Attribute
Sourcepub fn new(name: impl Into<String>, ty: AttrType) -> Self
pub fn new(name: impl Into<String>, ty: AttrType) -> Self
Declare a plain attribute with name and ty: no default.
This is a base to refine with struct-update syntax — the Rust way, in place of a builder chain. Set the fields you want and inherit the rest:
use ash_domain::attribute::{Attribute, AttrType};
use ash_domain::Value;
// A string primary key (identified by name via `Resource::primary_key`,
// not by any flag on the attribute).
let id = Attribute::scalar::<String>("id");
// A bool with a default.
let done = Attribute {
default: Some(Value::Bool(false)),
..Attribute::scalar::<bool>("done")
};The core validates none of these values on write — presence, ranges, and
formats are enforced by a Validation
registered on the action, not by attribute metadata.
Trait Implementations§
impl StructuralPartialEq for Attribute
Auto Trait Implementations§
impl !Freeze for Attribute
impl Forget for Attribute
impl Move for Attribute
impl RefUnwindSafe for Attribute
impl Send for Attribute
impl Sync for Attribute
impl Unpin for Attribute
impl UnsafeUnpin for Attribute
impl UnwindSafe for Attribute
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more