use alloc::{boxed::Box, format, rc::Rc};
use super::AttributeValue;
use crate::{
Attribute, Context, DialectRegistration, Type, UnsafeIntrusiveEntityRef, interner,
traits::TraitInfo,
};
pub trait AttributeRegistration: Attribute {
type Dialect: DialectRegistration;
type Value: AttributeValue;
fn dialect_name() -> interner::Symbol {
interner::Symbol::intern(
<<Self as AttributeRegistration>::Dialect as DialectRegistration>::NAMESPACE,
)
}
fn name() -> interner::Symbol;
fn full_name() -> interner::Symbol {
interner::Symbol::intern(format!(
"{}.{}",
Self::dialect_name(),
<Self as AttributeRegistration>::name()
))
}
fn traits() -> Box<[TraitInfo]>;
fn create<V>(context: &Rc<Context>, value: V, ty: Type) -> UnsafeIntrusiveEntityRef<Self>
where
Self::Value: From<V>;
fn create_default(context: &Rc<Context>) -> UnsafeIntrusiveEntityRef<Self>;
fn underlying_value(attr: &Self) -> &Self::Value;
fn underlying_value_mut(attr: &mut Self) -> &mut Self::Value;
}