pub struct HashChainEntry {
pub prev_hash: String,
pub current_hash: String,
pub entry: SqlAuditContext,
}Expand description
带哈希链的审计日志条目。
每条记录包含:
prev_hash:上一条记录的current_hash(首条为GENESIS_HASH)current_hash:本条记录的 SHA-256 哈希(基于prev_hash + entry计算)entry:原始审计上下文(已脱敏)
任何对历史记录的篡改都会导致 current_hash 与下一条记录的 prev_hash 不匹配,
从而被 verify_chain 检测出来。
Fields§
§prev_hash: String上一条记录的哈希(首条为 GENESIS_HASH)
current_hash: String本条记录的哈希(SHA-256 十六进制串,64 字符)
entry: SqlAuditContext原始审计上下文(已脱敏)
Implementations§
Source§impl HashChainEntry
impl HashChainEntry
Sourcepub fn genesis(entry: SqlAuditContext) -> Self
pub fn genesis(entry: SqlAuditContext) -> Self
创建链首记录(prev_hash = GENESIS_HASH)
Sourcepub fn append(prev_hash: &str, entry: SqlAuditContext) -> Self
pub fn append(prev_hash: &str, entry: SqlAuditContext) -> Self
在指定前置哈希上追加一条记录
Trait Implementations§
Source§impl Clone for HashChainEntry
impl Clone for HashChainEntry
Source§fn clone(&self) -> HashChainEntry
fn clone(&self) -> HashChainEntry
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for HashChainEntry
impl Debug for HashChainEntry
Source§impl<'de> Deserialize<'de> for HashChainEntry
impl<'de> Deserialize<'de> for HashChainEntry
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for HashChainEntry
impl RefUnwindSafe for HashChainEntry
impl Send for HashChainEntry
impl Sync for HashChainEntry
impl Unpin for HashChainEntry
impl UnsafeUnpin for HashChainEntry
impl UnwindSafe for HashChainEntry
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