Skip to main content

muse_code_sdk/
fingerprint.rs

1//! Stable schema pin and compatibility warning.
2
3/// The stable fingerprint this release expects; a compatibility test keeps it equal to
4/// the committed stable manifest and the generated protocol fingerprint.
5pub const EXPECTED: &str = crate::msp::GENERATED_FINGERPRINT;
6
7/// A newer (or older) host reports a different fingerprint. Warning-only:
8/// clients may still use compatible methods without losing the session.
9#[derive(Debug, Clone, PartialEq, Eq)]
10pub struct FingerprintWarning {
11    /// The fingerprint this SDK release was generated from.
12    pub expected: &'static str,
13    /// The fingerprint the host reported.
14    pub actual: String,
15}
16
17impl FingerprintWarning {
18    /// Returns a warning on mismatch, without refusing any independent action.
19    #[must_use]
20    pub fn for_server(actual: impl Into<String>) -> Option<Self> {
21        let actual = actual.into();
22        (actual != EXPECTED).then_some(Self {
23            expected: EXPECTED,
24            actual,
25        })
26    }
27}