From 4eaca15ad355572c287ec7939737cf7303be62fd Mon Sep 17 00:00:00 2001 From: Kilian Strunz Date: Wed, 25 Mar 2026 09:46:43 +0100 Subject: [PATCH 1/3] impl as unstable --- crates/bindings/src/lib.rs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/crates/bindings/src/lib.rs b/crates/bindings/src/lib.rs index 9e02a3a97f0..1f1cf39f3eb 100644 --- a/crates/bindings/src/lib.rs +++ b/crates/bindings/src/lib.rs @@ -1460,6 +1460,15 @@ pub trait DbContext { /// Currently, being this generic is only meaningful in clients, /// as `ReducerContext` is the only implementor of `DbContext` within modules. fn db(&self) -> &Self::DbView; + + /// Get a read-only view into the tables. + /// + /// This method is provided for times when a programmer wants to be generic over the `DbContext` type. + /// Concrete-typed code is expected to read the `.db` field off the particular `DbContext` implementor. + /// Currently, being this generic is only meaningful in clients, + /// as `ReducerContext` is the only implementor of `DbContext` within modules. + #[cfg(feature = "unstable")] + fn db_read_only(&self) -> &LocalReadOnly; } impl DbContext for AnonymousViewContext { @@ -1468,6 +1477,11 @@ impl DbContext for AnonymousViewContext { fn db(&self) -> &Self::DbView { &self.db } + + #[cfg(feature = "unstable")] + fn db_read_only(&self) -> &LocalReadOnly { + &self.db + } } impl DbContext for ReducerContext { @@ -1476,6 +1490,11 @@ impl DbContext for ReducerContext { fn db(&self) -> &Self::DbView { &self.db } + + #[cfg(feature = "unstable")] + fn db_read_only(&self) -> &LocalReadOnly { + self.db.get_read_only() + } } #[cfg(feature = "unstable")] @@ -1485,6 +1504,10 @@ impl DbContext for TxContext { fn db(&self) -> &Self::DbView { &self.db } + + fn db_read_only(&self) -> &LocalReadOnly { + self.db.get_read_only() + } } impl DbContext for ViewContext { @@ -1493,6 +1516,11 @@ impl DbContext for ViewContext { fn db(&self) -> &Self::DbView { &self.db } + + #[cfg(feature = "unstable")] + fn db_read_only(&self) -> &LocalReadOnly { + &self.db + } } // `ProcedureContext` is *not* a `DbContext` @@ -1506,6 +1534,12 @@ impl DbContext for ViewContext { #[non_exhaustive] pub struct Local {} +impl Local { + fn get_read_only(&self) -> &LocalReadOnly { + &LocalReadOnly {} + } +} + /// The [JWT] of an [`AuthCtx`]. /// /// [JWT]: https://en.wikipedia.org/wiki/JSON_Web_Token From 0f502c1ae0438cc54f3b8b1094b6ca43d2b9768e Mon Sep 17 00:00:00 2001 From: "kistz (Kilian Strunz)" Date: Tue, 28 Apr 2026 21:21:56 +0200 Subject: [PATCH 2/3] remove outdated comments --- crates/bindings/src/lib.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/crates/bindings/src/lib.rs b/crates/bindings/src/lib.rs index 1f1cf39f3eb..acf3ab81691 100644 --- a/crates/bindings/src/lib.rs +++ b/crates/bindings/src/lib.rs @@ -1457,16 +1457,12 @@ pub trait DbContext { /// /// This method is provided for times when a programmer wants to be generic over the `DbContext` type. /// Concrete-typed code is expected to read the `.db` field off the particular `DbContext` implementor. - /// Currently, being this generic is only meaningful in clients, - /// as `ReducerContext` is the only implementor of `DbContext` within modules. fn db(&self) -> &Self::DbView; /// Get a read-only view into the tables. /// /// This method is provided for times when a programmer wants to be generic over the `DbContext` type. /// Concrete-typed code is expected to read the `.db` field off the particular `DbContext` implementor. - /// Currently, being this generic is only meaningful in clients, - /// as `ReducerContext` is the only implementor of `DbContext` within modules. #[cfg(feature = "unstable")] fn db_read_only(&self) -> &LocalReadOnly; } From 0d83fbfe75730d8458bfc977f8d4927b26d968d2 Mon Sep 17 00:00:00 2001 From: clockwork-labs-bot Date: Mon, 4 May 2026 13:06:11 -0400 Subject: [PATCH 3/3] Gate read-only helper behind unstable --- crates/bindings/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/bindings/src/lib.rs b/crates/bindings/src/lib.rs index acf3ab81691..6d7144ab2db 100644 --- a/crates/bindings/src/lib.rs +++ b/crates/bindings/src/lib.rs @@ -1531,6 +1531,7 @@ impl DbContext for ViewContext { pub struct Local {} impl Local { + #[cfg(feature = "unstable")] fn get_read_only(&self) -> &LocalReadOnly { &LocalReadOnly {} }