surrealpatch/lib/src/sql/serde.rs
2022-05-21 10:07:32 +01:00

18 lines
502 B
Rust

use std::sync::atomic::AtomicBool;
use std::sync::atomic::Ordering;
thread_local! {
static INTERNAL_SERIALIZATION: AtomicBool = AtomicBool::new(false);
}
pub(crate) fn is_internal_serialization() -> bool {
INTERNAL_SERIALIZATION.with(|v| v.load(Ordering::Relaxed))
}
pub(crate) fn beg_internal_serialization() {
INTERNAL_SERIALIZATION.with(|v| v.store(true, Ordering::Relaxed))
}
pub(crate) fn end_internal_serialization() {
INTERNAL_SERIALIZATION.with(|v| v.store(false, Ordering::Relaxed))
}