Skip to main content

eln_plugin_sdk/
api_key.rs

1//! Plugin · 외부 호출자에게 발급되는 API key.
2//!
3//! S2는 타입 자리만. hash / signature / registry / validation 로직은 S3 scope.
4
5use std::fmt;
6
7#[derive(Clone, PartialEq, Eq, Hash)]
8pub struct ApiKey(String);
9
10impl ApiKey {
11    pub fn new<S: Into<String>>(raw: S) -> Self {
12        Self(raw.into())
13    }
14
15    /// Raw secret accessor. caller가 비교·validation 시에만 사용.
16    pub fn expose_secret(&self) -> &str {
17        &self.0
18    }
19}
20
21impl fmt::Debug for ApiKey {
22    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
23        write!(f, "ApiKey(***masked***)")
24    }
25}
26
27impl fmt::Display for ApiKey {
28    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
29        write!(f, "***masked***")
30    }
31}