1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
use crate::prelude::*;
///
/// PrimaryKey
///
/// Structured primary-key metadata for an entity schema.
///
#[derive(Clone, Debug, Serialize)]
pub struct PrimaryKey {
field: &'static str,
#[serde(default)]
source: PrimaryKeySource,
}
impl PrimaryKey {
/// Build one primary-key declaration from field name and source.
#[must_use]
pub const fn new(field: &'static str, source: PrimaryKeySource) -> Self {
Self { field, source }
}
/// Borrow the primary-key field name.
#[must_use]
pub const fn field(&self) -> &'static str {
self.field
}
/// Borrow the primary-key source declaration.
#[must_use]
pub const fn source(&self) -> PrimaryKeySource {
self.source
}
}
///
/// PrimaryKeySource
///
/// Declares where primary-key values originate.
///
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Serialize)]
pub enum PrimaryKeySource {
#[default]
Internal,
External,
}