mz_storage_types/lib.rs
1// Copyright Materialize, Inc. and contributors. All rights reserved.
2//
3// Use of this software is governed by the Business Source License
4// included in the LICENSE file.
5//
6// As of the Change Date specified in that file, in accordance with
7// the Business Source License, use of this software will be governed
8// by the Apache License, Version 2.0.
9
10// TODO(parkmycar): Remove this allow.
11#![allow(unsafe_op_in_unsafe_fn)]
12
13//! Shared types for the `mz-storage*` crates
14
15pub mod configuration;
16pub mod connections;
17pub mod controller;
18pub mod dyncfgs;
19pub mod errors;
20pub mod instances;
21pub mod oneshot_sources;
22pub mod parameters;
23pub mod read_holds;
24pub mod read_policy;
25pub mod sinks;
26pub mod sources;
27pub mod stats;
28pub mod time_dependence;
29
30/// Explicitly states the contract between storage and higher levels of
31/// Materialize w/r/t which facets of objects managed by storage (e.g. sources,
32/// sinks, connections) may be altered.
33///
34/// n.b. when implementing this trait, leave a warning log with more details as
35/// to what the problem was, given that the returned error is scant on details.
36pub trait AlterCompatible: std::fmt::Debug + PartialEq {
37 fn alter_compatible(
38 &self,
39 id: mz_repr::GlobalId,
40 other: &Self,
41 ) -> Result<(), controller::AlterError> {
42 if self == other {
43 Ok(())
44 } else {
45 Err(controller::AlterError { id })
46 }
47 }
48}
49
50impl AlterCompatible for mz_repr::GlobalId {}
51impl AlterCompatible for mz_repr::CatalogItemId {}
52
53/// The diff type used by storage.
54pub type StorageDiff = i64;