Skip to main content

systemprompt_models/origin/
memory.rs

1//! The caller's team-memory preference, read from the
2//! `x-systemprompt-memory` request header.
3//!
4//! Copyright (c) systemprompt.io — Business Source License 1.1.
5//! See <https://systemprompt.io> for licensing details.
6
7use serde::{Deserialize, Serialize};
8
9/// Whether the caller allows team-memory recall on this request: `Off`
10/// only for a header value of `off` in any case, `Default` otherwise.
11#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
12#[serde(rename_all = "snake_case")]
13pub enum MemoryPreference {
14    #[default]
15    Default,
16    Off,
17}
18
19impl MemoryPreference {
20    #[must_use]
21    pub const fn from_header(value: Option<&str>) -> Self {
22        match value {
23            Some(value) if value.eq_ignore_ascii_case("off") => Self::Off,
24            _ => Self::Default,
25        }
26    }
27
28    #[must_use]
29    pub const fn is_off(self) -> bool {
30        matches!(self, Self::Off)
31    }
32}