Skip to main content

mysql_handler/engine/
reset_cached_state.rs

1// Copyright (C) 2026 ren-yamanashi
2//
3// This program is free software; you can redistribute it and/or modify
4// it under the terms of the GNU General Public License, version 2.0,
5// as published by the Free Software Foundation.
6//
7// This program is designed to work with certain software (including
8// but not limited to OpenSSL) that is licensed under separate terms,
9// as designated in a particular file or component or in included license
10// documentation. The authors of this program hereby grant you an additional
11// permission to link the program and your derivative works with the
12// separately licensed software that they have either included with
13// the program or referenced in the documentation.
14//
15// This program is distributed in the hope that it will be useful,
16// but WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18// GNU General Public License for more details.
19//
20// You should have received a copy of the GNU General Public License
21// along with this program; if not, see <https://www.gnu.org/licenses/>.
22
23//! Cached-state reset signal passed to engine-private metadata callbacks.
24
25/// Whether MySQL has just reset the data-dictionary entry and any cached
26/// engine-private metadata should be re-emitted from scratch
27#[derive(Debug, Clone, Copy, PartialEq, Eq)]
28#[non_exhaustive]
29pub enum ResetCachedState {
30    /// Reuse whatever the engine has cached
31    Keep,
32    /// Discard cached state and re-emit from authoritative source
33    Reset,
34}
35
36impl From<bool> for ResetCachedState {
37    fn from(needs_reset: bool) -> Self {
38        if needs_reset { Self::Reset } else { Self::Keep }
39    }
40}
41
42#[cfg(test)]
43mod tests {
44    use super::*;
45
46    #[test]
47    fn maps_bool_to_variant() {
48        assert_eq!(ResetCachedState::from(true), ResetCachedState::Reset);
49        assert_eq!(ResetCachedState::from(false), ResetCachedState::Keep);
50    }
51}