Diffstat (limited to 'src/mock/protocol/tag.rs')
| -rw-r--r-- | src/mock/protocol/tag.rs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/mock/protocol/tag.rs b/src/mock/protocol/tag.rs new file mode 100644 index 0000000..e1c9551 --- /dev/null +++ b/src/mock/protocol/tag.rs @@ -0,0 +1,33 @@ +use mockall::mock; + +use crate::{ + any_trait, + effect::{Effect, Future}, + protocol::visitor::tag::{DynTag, Tag, TagKind}, + DynWalker, +}; + +mock! { + pub TagVisitor<K: TagKind, E> { + pub fn visit<'a, 'ctx>(&'a mut self, kind: K, walker: DynWalker<'a, 'ctx, E>) -> K::Flow; + } +} + +any_trait! { + impl['ctx, K, E] MockTagVisitor<K, E> = [ + DynTag<'ctx, K, E>, + ] where + K: TagKind, + E: Effect<'ctx>, +} + +impl<'ctx, K: TagKind, E: Effect<'ctx>> Tag<'ctx, K, E> for MockTagVisitor<K, E> { + #[track_caller] + fn visit<'a>( + &'a mut self, + kind: K, + walker: DynWalker<'a, 'ctx, E>, + ) -> Future<'a, 'ctx, <K as TagKind>::Flow, E> { + E::ready(self.visit(kind, walker)) + } +} |