Diffstat (limited to 'tests/common/protocol/request_hint.rs')
| -rw-r--r-- | tests/common/protocol/request_hint.rs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/common/protocol/request_hint.rs b/tests/common/protocol/request_hint.rs new file mode 100644 index 0000000..be203b3 --- /dev/null +++ b/tests/common/protocol/request_hint.rs @@ -0,0 +1,33 @@ +use mockall::mock; +use treaty::{ + any::{any_trait, TypeName}, + effect::{Effect, Future}, + protocol::visitor::{RequestHint, RequestHintProto, Value, ValueProto, VisitResult}, + protocol::DynWalker, + Flow, +}; + +pub type RequestHintFactory = + for<'a, 'ctx> fn(&'ctx (), DynWalker<'a, 'ctx>) -> VisitResult<DynWalker<'a, 'ctx>>; + +mock! { + pub RequestHintVisitor<E> { + pub fn request_hint(&mut self) -> RequestHintFactory; + } +} + +any_trait! { + impl['ctx, E] MockRequestHintVisitor<E> = [ + RequestHintProto<E> + ] where + E: Effect, +} + +impl<'ctx, E: Effect> RequestHint<'ctx, E> for MockRequestHintVisitor<E> { + fn request_hint<'a>( + &'a mut self, + walker: DynWalker<'a, 'ctx>, + ) -> Future<'a, VisitResult<DynWalker<'a, 'ctx>>, E> { + E::ready(self.request_hint()(&(), walker)) + } +} |