#[derive(DbContextKey)]
{
// Attributes available to this derive:
#[key]
}
Expand description
Derive a typed keyed-DbContext key.
The enum’s variants become IDbContextKey::name() values (snake-case by
default, overridable with #[key("...")]) and the type implements
From<Key> for rust_dix::ServiceKey. This makes
#[inject(owned, key = Key::Read)] and add_dbcontext_keyed(Key::Read, ...)
share the same typed key.
ⓘ
#[derive(DbContextKey, Debug, Clone, Copy, PartialEq, Eq, Hash)]
enum Db {
Read,
Write,
#[key("audit-log")]
Audit,
}The enum must derive Debug + Clone + Copy + PartialEq + Eq + Hash (the
bounds required by rust_dix::ServiceKey::new).