core: implement display for typed ids
This commit is contained in:
@@ -2,18 +2,18 @@
|
|||||||
|
|
||||||
## Current
|
## Current
|
||||||
|
|
||||||
### `feat/id-display-support`
|
### `feat/secret-crypto-hkdf`
|
||||||
|
|
||||||
Status: in_progress
|
Status: in_progress
|
||||||
|
|
||||||
DoD:
|
DoD:
|
||||||
- `define_id!` implements `Display`
|
- master key derivation uses HKDF-SHA256 instead of raw SHA256
|
||||||
- formatting with typed ids no longer requires pervasive `.as_str()`
|
- secret encryption/decryption compatibility is explicit and tested
|
||||||
- the workspace builds cleanly after the macro change
|
- admin-api and runtime continue to handle secret crypto through the shared path
|
||||||
|
|
||||||
## Next
|
## Next
|
||||||
|
|
||||||
- `feat/secret-crypto-hkdf`
|
- `feat/postgres-pool-config`
|
||||||
|
|
||||||
## Backlog
|
## Backlog
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
use std::fmt;
|
||||||
|
|
||||||
macro_rules! define_id {
|
macro_rules! define_id {
|
||||||
($name:ident) => {
|
($name:ident) => {
|
||||||
@@ -32,6 +33,12 @@ macro_rules! define_id {
|
|||||||
self.as_str()
|
self.as_str()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for $name {
|
||||||
|
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
formatter.write_str(self.as_str())
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,3 +57,16 @@ define_id!(InvocationLogId);
|
|||||||
define_id!(SecretId);
|
define_id!(SecretId);
|
||||||
define_id!(StreamSessionId);
|
define_id!(StreamSessionId);
|
||||||
define_id!(AsyncJobId);
|
define_id!(AsyncJobId);
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn ids_implement_display() {
|
||||||
|
let workspace_id = WorkspaceId::new("ws_default");
|
||||||
|
|
||||||
|
assert_eq!(workspace_id.to_string(), "ws_default");
|
||||||
|
assert_eq!(format!("{workspace_id}"), "ws_default");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user