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 collections;
16pub mod configuration;
17pub mod connections;
18pub mod controller;
19pub mod dyncfgs;
20pub mod errors;
21pub mod instances;
22pub mod oneshot_sources;
23pub mod parameters;
24pub mod read_holds;
25pub mod read_policy;
26pub mod sinks;
27pub mod sources;
28pub mod stats;
29pub mod time_dependence;
30
31/// Explicitly states the contract between storage and higher levels of
32/// Materialize w/r/t which facets of objects managed by storage (e.g. sources,
33/// sinks, connections) may be altered.
34///
35/// n.b. when implementing this trait, leave a warning log with more details as
36/// to what the problem was, given that the returned error is scant on details.
37pub trait AlterCompatible: std::fmt::Debug + PartialEq {
38 fn alter_compatible(
39 &self,
40 id: mz_repr::GlobalId,
41 other: &Self,
42 ) -> Result<(), controller::AlterError> {
43 if self == other {
44 Ok(())
45 } else {
46 Err(controller::AlterError { id })
47 }
48 }
49}
50
51impl AlterCompatible for mz_repr::GlobalId {}
52impl AlterCompatible for mz_repr::CatalogItemId {}
53
54/// The diff type used by storage.
55pub type StorageDiff = i64;