pub struct Middleware { /* private fields */ }Expand description
A registered set of hooks. A host builds this with the builder methods and
passes it to crate::runtime::GraphDDBRuntime::use_middleware. Any subset of
the 10 hook points may be set; unset points are simply skipped.
Implementations§
Source§impl Middleware
impl Middleware
Sourcepub fn read_before(
self,
f: impl Fn(&mut ReadRequestCtx) -> Result<(), GraphDDBError> + Send + Sync + 'static,
) -> Self
pub fn read_before( self, f: impl Fn(&mut ReadRequestCtx) -> Result<(), GraphDDBError> + Send + Sync + 'static, ) -> Self
Register R1 read.before (request entry; may mutate params, may error).
Sourcepub fn read_after(
self,
f: impl Fn(&ReadRequestCtx, Json) -> Json + Send + Sync + 'static,
) -> Self
pub fn read_after( self, f: impl Fn(&ReadRequestCtx, Json) -> Json + Send + Sync + 'static, ) -> Self
Register R4 read.afterFetch (final result; onion-threaded, may replace).
Sourcepub fn read_on_error(
self,
f: impl Fn(&ReadRequestCtx, &GraphDDBError) -> Recovery + Send + Sync + 'static,
) -> Self
pub fn read_on_error( self, f: impl Fn(&ReadRequestCtx, &GraphDDBError) -> Recovery + Send + Sync + 'static, ) -> Self
Register R5 read.onError (request-level recovery).
Sourcepub fn read_op_before(
self,
f: impl Fn(&mut ReadOpCtx) -> Result<(), GraphDDBError> + Send + Sync + 'static,
) -> Self
pub fn read_op_before( self, f: impl Fn(&mut ReadOpCtx) -> Result<(), GraphDDBError> + Send + Sync + 'static, ) -> Self
Register R2 read.op.before (physical op; may mutate the op, may error).
Sourcepub fn read_op_after(
self,
f: impl Fn(&ReadOpCtx, Vec<Json>) -> Vec<Json> + Send + Sync + 'static,
) -> Self
pub fn read_op_after( self, f: impl Fn(&ReadOpCtx, Vec<Json>) -> Vec<Json> + Send + Sync + 'static, ) -> Self
Register R3 read.op.afterFetch (raw items; onion-threaded, may replace).
Sourcepub fn read_op_on_error(
self,
f: impl Fn(&ReadOpCtx, &GraphDDBError) -> Option<Vec<Json>> + Send + Sync + 'static,
) -> Self
pub fn read_op_on_error( self, f: impl Fn(&ReadOpCtx, &GraphDDBError) -> Option<Vec<Json>> + Send + Sync + 'static, ) -> Self
Register R5 (op-level) read.op.onError (recover with an item list).
Sourcepub fn write_before(
self,
f: impl Fn(&mut WriteCtx) -> Result<(), GraphDDBError> + Send + Sync + 'static,
) -> Self
pub fn write_before( self, f: impl Fn(&mut WriteCtx) -> Result<(), GraphDDBError> + Send + Sync + 'static, ) -> Self
Register W1 write.before (logical write; may mutate kind/input, may error).
Sourcepub fn write_after(
self,
f: impl Fn(&WriteCtx, &Json) + Send + Sync + 'static,
) -> Self
pub fn write_after( self, f: impl Fn(&WriteCtx, &Json) + Send + Sync + 'static, ) -> Self
Register W2 write.after (committed change; observe-only).
Sourcepub fn write_on_error(
self,
f: impl Fn(&WriteCtx, &GraphDDBError) -> Recovery + Send + Sync + 'static,
) -> Self
pub fn write_on_error( self, f: impl Fn(&WriteCtx, &GraphDDBError) -> Recovery + Send + Sync + 'static, ) -> Self
Register W5 (logical-level) write.onError (recovery).
Sourcepub fn persist_before(
self,
f: impl Fn(&mut PersistCtx) -> Result<(), GraphDDBError> + Send + Sync + 'static,
) -> Self
pub fn persist_before( self, f: impl Fn(&mut PersistCtx) -> Result<(), GraphDDBError> + Send + Sync + 'static, ) -> Self
Register W3 write.persist.before (composed batch; may mutate items, may error).
Sourcepub fn persist_after(
self,
f: impl Fn(&PersistCtx, &Json) + Send + Sync + 'static,
) -> Self
pub fn persist_after( self, f: impl Fn(&PersistCtx, &Json) + Send + Sync + 'static, ) -> Self
Register W4 write.persist.after (executor results; observe-only).
Sourcepub fn persist_on_error(
self,
f: impl Fn(&PersistCtx, &GraphDDBError) -> Recovery + Send + Sync + 'static,
) -> Self
pub fn persist_on_error( self, f: impl Fn(&PersistCtx, &GraphDDBError) -> Recovery + Send + Sync + 'static, ) -> Self
Register W5 (persist-level) write.persist.onError (recovery).
Trait Implementations§
Source§impl Clone for Middleware
impl Clone for Middleware
Source§fn clone(&self) -> Middleware
fn clone(&self) -> Middleware
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Default for Middleware
impl Default for Middleware
Source§fn default() -> Middleware
fn default() -> Middleware
Auto Trait Implementations§
impl !RefUnwindSafe for Middleware
impl !UnwindSafe for Middleware
impl Freeze for Middleware
impl Send for Middleware
impl Sync for Middleware
impl Unpin for Middleware
impl UnsafeUnpin for Middleware
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more