// @generated by Thrift for thrift/compiler/test/fixtures/interactions/src/module.thrift // This file is probably not the place you want to edit! //! Mock definitions for `module`. //! //! Client mocks. For every service, a struct TheService that implements //! client::TheService. //! //! As an example of the generated API, for the following thrift service in //! example.thrift: //! //! ```thrift //! service MyService { //! FunctionResponse myFunction( //! 1: FunctionRequest request, //! ) throws { //! 1: StorageException s, //! 2: NotFoundException n, //! ), //! //! // other functions //! } //! ``` //! //! we would end up with this mock object in an `example_mocks` crate: //! //! ``` //! # const _: &str = stringify! { //! impl example_clients::MyService for MyService<'mock> {...} //! //! pub struct MyService<'mock> { //! pub myFunction: myFunction<'mock>, //! // ... //! } //! //! impl myFunction<'mock> { //! // directly return the given success response //! pub fn ret(&self, value: FunctionResponse); //! //! // invoke closure to compute success response //! pub fn mock( //! &self, //! mock: impl FnMut(FunctionRequest) -> FunctionResponse + Send + Sync + 'mock, //! ); //! //! // invoke closure to compute response //! pub fn mock_result( //! &self, //! mock: impl FnMut(FunctionRequest) -> Result + Send + Sync + 'mock, //! ); //! //! // return one of the function's declared exceptions //! pub fn throw(&self, exception: E) //! where //! E: Clone + Into + Send + Sync + 'mock; //! } //! # }; //! ``` //! //! The intended usage from a test would be: //! //! ``` //! # const _: &str = stringify! { //! use std::sync::Arc; //! use example_clients::MyService; //! //! #[tokio::test] //! async fn test_my_client() { //! let mock = Arc::new(example_mocks::new::()); //! //! // directly return a success response //! let resp = FunctionResponse {...}; //! mock.myFunction.ret(resp); //! //! // or give a closure to compute the success response //! mock.myFunction.mock(|request| FunctionResponse {...}); //! //! // or throw one of the function's exceptions //! mock.myFunction.throw(StorageException::ItFailed); //! //! // or compute a Result (useful if your exceptions aren't Clone) //! mock.myFunction.mock_result(|request| Err(...)); //! //! let out = do_the_thing(mock).await.unwrap(); //! assert!(out.what_i_expected()); //! } //! //! async fn do_the_thing( //! client: Arc, //! ) -> Out {...} //! # }; //! ``` #![recursion_limit = "100000000"] #![allow(non_camel_case_types, non_snake_case, non_upper_case_globals, unused_crate_dependencies, unused_imports, clippy::all)] pub(crate) use :: as types; pub(crate) use :: as client; pub(crate) use ::::errors; pub fn new<'mock, Client>() -> Client::Mock<'mock> where Client: ?::std::marker::Sized + DynClient, { Client::mock() } pub trait DynClient { type Mock<'mock>; fn mock<'mock>() -> Self::Mock<'mock>; } pub struct MyService<'mock> { pub foo: r#impl::my_service::foo<'mock>, pub interact: r#impl::my_service::interact<'mock>, pub interactFast: r#impl::my_service::interactFast<'mock>, pub serialize: r#impl::my_service::serialize<'mock>, _marker: ::std::marker::PhantomData<&'mock ()>, } impl crate::DynClient for dyn ::::MyService { type Mock<'mock> = MyService<'mock>; fn mock<'mock>() -> Self::Mock<'mock> { MyService { foo: r#impl::my_service::foo::unimplemented(), interact: r#impl::my_service::interact::unimplemented(), interactFast: r#impl::my_service::interactFast::unimplemented(), serialize: r#impl::my_service::serialize::unimplemented(), _marker: ::std::marker::PhantomData, } } } impl<'mock> ::::MyService for MyService<'mock> { fn createMyInteraction( &self, ) -> ::std::result::Result { unimplemented!("Mocking interactions is not yet implemented"); } fn createMyInteractionFast( &self, ) -> ::std::result::Result { unimplemented!("Mocking interactions is not yet implemented"); } fn createSerialInteraction( &self, ) -> ::std::result::Result { unimplemented!("Mocking interactions is not yet implemented"); } fn foo( &self, ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<(), crate::errors::my_service::FooError>> { let mut closure = self.foo.closure.lock().unwrap(); let closure: &mut dyn ::std::ops::FnMut() -> _ = &mut **closure; ::std::boxed::Box::pin(::futures::future::ready(closure())) } fn interact( &self, _arg_arg: ::std::primitive::i32, ) -> ::futures::future::BoxFuture<'static, ::std::result::Result> { unimplemented!("Mocking interactions is not yet implemented"); } fn interactFast( &self, ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<(crate::client::my_service::MyInteractionFastClient, ::std::primitive::i32), crate::errors::my_service::InteractFastError>> { unimplemented!("Mocking interactions is not yet implemented"); } fn serialize( &self, ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<(crate::client::my_service::SerialInteractionClient, (::std::primitive::i32, ::futures::stream::BoxStream<'static, ::std::result::Result<::std::primitive::i32, crate::errors::my_service::SerializeStreamError>>)), crate::errors::my_service::SerializeError>> { unimplemented!("Mocking interactions is not yet implemented"); } } impl<'mock, T> ::::MyServiceExt for MyService<'mock> where T: ::fbthrift::Transport, { fn foo_with_rpc_opts( &self, _rpc_options: T::RpcOptions, ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<(), crate::errors::my_service::FooError>> { ::foo( self, ) } fn interact_with_rpc_opts( &self, arg_arg: ::std::primitive::i32, _rpc_options: T::RpcOptions, ) -> ::futures::future::BoxFuture<'static, ::std::result::Result> { ::interact( self, arg_arg, ) } fn interactFast_with_rpc_opts( &self, _rpc_options: T::RpcOptions, ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<(crate::client::my_service::MyInteractionFastClient, ::std::primitive::i32), crate::errors::my_service::InteractFastError>> { ::interactFast( self, ) } fn serialize_with_rpc_opts( &self, _rpc_options: T::RpcOptions, ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<(crate::client::my_service::SerialInteractionClient, (::std::primitive::i32, ::futures::stream::BoxStream<'static, ::std::result::Result<::std::primitive::i32, crate::errors::my_service::SerializeStreamError>>)), crate::errors::my_service::SerializeError>> { ::serialize( self, ) } fn transport(&self) -> &T { ::fbthrift::help::GetTransport::transport(self) } } impl<'mock, T> ::fbthrift::help::GetTransport for MyService<'mock> where T: ::fbthrift::Transport, { fn transport(&self) -> &T { unimplemented!("MyServiceExt::transport is not implemented for mock client") } } pub struct Factories<'mock> { pub foo: r#impl::factories::foo<'mock>, pub interact: r#impl::factories::interact<'mock>, pub interactFast: r#impl::factories::interactFast<'mock>, pub serialize: r#impl::factories::serialize<'mock>, _marker: ::std::marker::PhantomData<&'mock ()>, } impl crate::DynClient for dyn ::::Factories { type Mock<'mock> = Factories<'mock>; fn mock<'mock>() -> Self::Mock<'mock> { Factories { foo: r#impl::factories::foo::unimplemented(), interact: r#impl::factories::interact::unimplemented(), interactFast: r#impl::factories::interactFast::unimplemented(), serialize: r#impl::factories::serialize::unimplemented(), _marker: ::std::marker::PhantomData, } } } impl<'mock> ::::Factories for Factories<'mock> { fn foo( &self, ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<(), crate::errors::factories::FooError>> { let mut closure = self.foo.closure.lock().unwrap(); let closure: &mut dyn ::std::ops::FnMut() -> _ = &mut **closure; ::std::boxed::Box::pin(::futures::future::ready(closure())) } fn interact( &self, _arg_arg: ::std::primitive::i32, ) -> ::futures::future::BoxFuture<'static, ::std::result::Result> { unimplemented!("Mocking interactions is not yet implemented"); } fn interactFast( &self, ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<(crate::client::factories::MyInteractionFastClient, ::std::primitive::i32), crate::errors::factories::InteractFastError>> { unimplemented!("Mocking interactions is not yet implemented"); } fn serialize( &self, ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<(crate::client::factories::SerialInteractionClient, (::std::primitive::i32, ::futures::stream::BoxStream<'static, ::std::result::Result<::std::primitive::i32, crate::errors::factories::SerializeStreamError>>)), crate::errors::factories::SerializeError>> { unimplemented!("Mocking interactions is not yet implemented"); } } impl<'mock, T> ::::FactoriesExt for Factories<'mock> where T: ::fbthrift::Transport, { fn foo_with_rpc_opts( &self, _rpc_options: T::RpcOptions, ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<(), crate::errors::factories::FooError>> { ::foo( self, ) } fn interact_with_rpc_opts( &self, arg_arg: ::std::primitive::i32, _rpc_options: T::RpcOptions, ) -> ::futures::future::BoxFuture<'static, ::std::result::Result> { ::interact( self, arg_arg, ) } fn interactFast_with_rpc_opts( &self, _rpc_options: T::RpcOptions, ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<(crate::client::factories::MyInteractionFastClient, ::std::primitive::i32), crate::errors::factories::InteractFastError>> { ::interactFast( self, ) } fn serialize_with_rpc_opts( &self, _rpc_options: T::RpcOptions, ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<(crate::client::factories::SerialInteractionClient, (::std::primitive::i32, ::futures::stream::BoxStream<'static, ::std::result::Result<::std::primitive::i32, crate::errors::factories::SerializeStreamError>>)), crate::errors::factories::SerializeError>> { ::serialize( self, ) } fn transport(&self) -> &T { ::fbthrift::help::GetTransport::transport(self) } } impl<'mock, T> ::fbthrift::help::GetTransport for Factories<'mock> where T: ::fbthrift::Transport, { fn transport(&self) -> &T { unimplemented!("FactoriesExt::transport is not implemented for mock client") } } pub struct Perform<'mock> { pub foo: r#impl::perform::foo<'mock>, _marker: ::std::marker::PhantomData<&'mock ()>, } impl crate::DynClient for dyn ::::Perform { type Mock<'mock> = Perform<'mock>; fn mock<'mock>() -> Self::Mock<'mock> { Perform { foo: r#impl::perform::foo::unimplemented(), _marker: ::std::marker::PhantomData, } } } impl<'mock> ::::Perform for Perform<'mock> { fn createMyInteraction( &self, ) -> ::std::result::Result { unimplemented!("Mocking interactions is not yet implemented"); } fn createMyInteractionFast( &self, ) -> ::std::result::Result { unimplemented!("Mocking interactions is not yet implemented"); } fn createSerialInteraction( &self, ) -> ::std::result::Result { unimplemented!("Mocking interactions is not yet implemented"); } fn foo( &self, ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<(), crate::errors::perform::FooError>> { let mut closure = self.foo.closure.lock().unwrap(); let closure: &mut dyn ::std::ops::FnMut() -> _ = &mut **closure; ::std::boxed::Box::pin(::futures::future::ready(closure())) } } impl<'mock, T> ::::PerformExt for Perform<'mock> where T: ::fbthrift::Transport, { fn foo_with_rpc_opts( &self, _rpc_options: T::RpcOptions, ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<(), crate::errors::perform::FooError>> { ::foo( self, ) } fn transport(&self) -> &T { ::fbthrift::help::GetTransport::transport(self) } } impl<'mock, T> ::fbthrift::help::GetTransport for Perform<'mock> where T: ::fbthrift::Transport, { fn transport(&self) -> &T { unimplemented!("PerformExt::transport is not implemented for mock client") } } pub struct InteractWithShared<'mock> { pub do_some_similar_things: r#impl::interact_with_shared::do_some_similar_things<'mock>, _marker: ::std::marker::PhantomData<&'mock ()>, } impl crate::DynClient for dyn ::::InteractWithShared { type Mock<'mock> = InteractWithShared<'mock>; fn mock<'mock>() -> Self::Mock<'mock> { InteractWithShared { do_some_similar_things: r#impl::interact_with_shared::do_some_similar_things::unimplemented(), _marker: ::std::marker::PhantomData, } } } impl<'mock> ::::InteractWithShared for InteractWithShared<'mock> { fn do_some_similar_things( &self, ) -> ::futures::future::BoxFuture<'static, ::std::result::Result> { let mut closure = self.do_some_similar_things.closure.lock().unwrap(); let closure: &mut dyn ::std::ops::FnMut() -> _ = &mut **closure; ::std::boxed::Box::pin(::futures::future::ready(closure())) } fn createMyInteraction( &self, ) -> ::std::result::Result { unimplemented!("Mocking interactions is not yet implemented"); } fn createshared.SharedInteraction( &self, ) -> ::std::result::Result { unimplemented!("Mocking interactions is not yet implemented"); } } impl<'mock, T> ::::InteractWithSharedExt for InteractWithShared<'mock> where T: ::fbthrift::Transport, { fn do_some_similar_things_with_rpc_opts( &self, _rpc_options: T::RpcOptions, ) -> ::futures::future::BoxFuture<'static, ::std::result::Result> { ::do_some_similar_things( self, ) } fn transport(&self) -> &T { ::fbthrift::help::GetTransport::transport(self) } } impl<'mock, T> ::fbthrift::help::GetTransport for InteractWithShared<'mock> where T: ::fbthrift::Transport, { fn transport(&self) -> &T { unimplemented!("InteractWithSharedExt::transport is not implemented for mock client") } } pub mod r#impl { pub mod my_service { pub struct foo<'mock> { pub(crate) closure: ::std::sync::Mutex<::std::boxed::Box< dyn ::std::ops::FnMut() -> ::std::result::Result< (), ::::errors::my_service::FooError, > + ::std::marker::Send + ::std::marker::Sync + 'mock, >>, } #[allow(clippy::redundant_closure)] impl<'mock> foo<'mock> { pub(crate) fn unimplemented() -> Self { Self { closure: ::std::sync::Mutex::new(::std::boxed::Box::new(|| panic!( "{}::{} is not mocked", "MyService", "foo", ))), } } pub fn ret(&self, value: ()) { self.mock(move || value.clone()); } pub fn mock(&self, mut mock: impl ::std::ops::FnMut() -> () + ::std::marker::Send + ::std::marker::Sync + 'mock) { let mut closure = self.closure.lock().unwrap(); *closure = ::std::boxed::Box::new(move || ::std::result::Result::Ok(mock())); } pub fn mock_result(&self, mut mock: impl ::std::ops::FnMut() -> ::std::result::Result<(), ::::errors::my_service::FooError> + ::std::marker::Send + ::std::marker::Sync + 'mock) { let mut closure = self.closure.lock().unwrap(); *closure = ::std::boxed::Box::new(move || mock()); } pub fn throw(&self, exception: E) where E: ::std::convert::Into<::::errors::my_service::FooError>, E: ::std::clone::Clone + ::std::marker::Send + ::std::marker::Sync + 'mock, { let mut closure = self.closure.lock().unwrap(); *closure = ::std::boxed::Box::new(move || ::std::result::Result::Err(exception.clone().into())); } } pub struct interact<'mock> { pub(crate) closure: ::std::sync::Mutex<::std::boxed::Box< dyn ::std::ops::FnMut(::std::primitive::i32) -> ::std::result::Result< (), ::::errors::my_service::InteractError, > + ::std::marker::Send + ::std::marker::Sync + 'mock, >>, } #[allow(clippy::redundant_closure)] impl<'mock> interact<'mock> { pub(crate) fn unimplemented() -> Self { Self { closure: ::std::sync::Mutex::new(::std::boxed::Box::new(|_: ::std::primitive::i32| panic!( "{}::{} is not mocked", "MyService", "interact", ))), } } pub fn ret(&self, value: ()) { self.mock(move |_: ::std::primitive::i32| value.clone()); } pub fn mock(&self, mut mock: impl ::std::ops::FnMut(::std::primitive::i32) -> () + ::std::marker::Send + ::std::marker::Sync + 'mock) { let mut closure = self.closure.lock().unwrap(); *closure = ::std::boxed::Box::new(move |arg| ::std::result::Result::Ok(mock(arg))); } pub fn mock_result(&self, mut mock: impl ::std::ops::FnMut(::std::primitive::i32) -> ::std::result::Result<(), ::::errors::my_service::InteractError> + ::std::marker::Send + ::std::marker::Sync + 'mock) { let mut closure = self.closure.lock().unwrap(); *closure = ::std::boxed::Box::new(move |arg| mock(arg)); } pub fn throw(&self, exception: E) where E: ::std::convert::Into<::::errors::my_service::InteractError>, E: ::std::clone::Clone + ::std::marker::Send + ::std::marker::Sync + 'mock, { let mut closure = self.closure.lock().unwrap(); *closure = ::std::boxed::Box::new(move |_: ::std::primitive::i32| ::std::result::Result::Err(exception.clone().into())); } } pub struct interactFast<'mock> { pub(crate) closure: ::std::sync::Mutex<::std::boxed::Box< dyn ::std::ops::FnMut() -> ::std::result::Result< ::std::primitive::i32, ::::errors::my_service::InteractFastError, > + ::std::marker::Send + ::std::marker::Sync + 'mock, >>, } #[allow(clippy::redundant_closure)] impl<'mock> interactFast<'mock> { pub(crate) fn unimplemented() -> Self { Self { closure: ::std::sync::Mutex::new(::std::boxed::Box::new(|| panic!( "{}::{} is not mocked", "MyService", "interactFast", ))), } } pub fn ret(&self, value: ::std::primitive::i32) { self.mock(move || value.clone()); } pub fn mock(&self, mut mock: impl ::std::ops::FnMut() -> ::std::primitive::i32 + ::std::marker::Send + ::std::marker::Sync + 'mock) { let mut closure = self.closure.lock().unwrap(); *closure = ::std::boxed::Box::new(move || ::std::result::Result::Ok(mock())); } pub fn mock_result(&self, mut mock: impl ::std::ops::FnMut() -> ::std::result::Result<::std::primitive::i32, ::::errors::my_service::InteractFastError> + ::std::marker::Send + ::std::marker::Sync + 'mock) { let mut closure = self.closure.lock().unwrap(); *closure = ::std::boxed::Box::new(move || mock()); } pub fn throw(&self, exception: E) where E: ::std::convert::Into<::::errors::my_service::InteractFastError>, E: ::std::clone::Clone + ::std::marker::Send + ::std::marker::Sync + 'mock, { let mut closure = self.closure.lock().unwrap(); *closure = ::std::boxed::Box::new(move || ::std::result::Result::Err(exception.clone().into())); } } pub struct serialize<'mock> { pub(crate) closure: ::std::sync::Mutex<::std::boxed::Box< dyn ::std::ops::FnMut() -> ::std::result::Result< (::std::primitive::i32, ::futures::stream::BoxStream<'static, ::std::result::Result<::std::primitive::i32, crate::errors::my_service::SerializeStreamError>>), ::::errors::my_service::SerializeError, > + ::std::marker::Send + ::std::marker::Sync + 'mock, >>, } #[allow(clippy::redundant_closure)] impl<'mock> serialize<'mock> { pub(crate) fn unimplemented() -> Self { Self { closure: ::std::sync::Mutex::new(::std::boxed::Box::new(|| panic!( "{}::{} is not mocked", "MyService", "serialize", ))), } } pub fn ret(&self, _value: (::std::primitive::i32, ::futures::stream::BoxStream<'static, ::std::result::Result<::std::primitive::i32, crate::errors::my_service::SerializeStreamError>>)) { unimplemented!("Mocking streams is not yet implemented, as value isn't cloneable") } pub fn mock(&self, mut mock: impl ::std::ops::FnMut() -> (::std::primitive::i32, ::futures::stream::BoxStream<'static, ::std::result::Result<::std::primitive::i32, crate::errors::my_service::SerializeStreamError>>) + ::std::marker::Send + ::std::marker::Sync + 'mock) { let mut closure = self.closure.lock().unwrap(); *closure = ::std::boxed::Box::new(move || ::std::result::Result::Ok(mock())); } pub fn mock_result(&self, mut mock: impl ::std::ops::FnMut() -> ::std::result::Result<(::std::primitive::i32, ::futures::stream::BoxStream<'static, ::std::result::Result<::std::primitive::i32, crate::errors::my_service::SerializeStreamError>>), ::::errors::my_service::SerializeError> + ::std::marker::Send + ::std::marker::Sync + 'mock) { let mut closure = self.closure.lock().unwrap(); *closure = ::std::boxed::Box::new(move || mock()); } pub fn throw(&self, exception: E) where E: ::std::convert::Into<::::errors::my_service::SerializeError>, E: ::std::clone::Clone + ::std::marker::Send + ::std::marker::Sync + 'mock, { let mut closure = self.closure.lock().unwrap(); *closure = ::std::boxed::Box::new(move || ::std::result::Result::Err(exception.clone().into())); } } } pub mod factories { pub struct foo<'mock> { pub(crate) closure: ::std::sync::Mutex<::std::boxed::Box< dyn ::std::ops::FnMut() -> ::std::result::Result< (), ::::errors::factories::FooError, > + ::std::marker::Send + ::std::marker::Sync + 'mock, >>, } #[allow(clippy::redundant_closure)] impl<'mock> foo<'mock> { pub(crate) fn unimplemented() -> Self { Self { closure: ::std::sync::Mutex::new(::std::boxed::Box::new(|| panic!( "{}::{} is not mocked", "Factories", "foo", ))), } } pub fn ret(&self, value: ()) { self.mock(move || value.clone()); } pub fn mock(&self, mut mock: impl ::std::ops::FnMut() -> () + ::std::marker::Send + ::std::marker::Sync + 'mock) { let mut closure = self.closure.lock().unwrap(); *closure = ::std::boxed::Box::new(move || ::std::result::Result::Ok(mock())); } pub fn mock_result(&self, mut mock: impl ::std::ops::FnMut() -> ::std::result::Result<(), ::::errors::factories::FooError> + ::std::marker::Send + ::std::marker::Sync + 'mock) { let mut closure = self.closure.lock().unwrap(); *closure = ::std::boxed::Box::new(move || mock()); } pub fn throw(&self, exception: E) where E: ::std::convert::Into<::::errors::factories::FooError>, E: ::std::clone::Clone + ::std::marker::Send + ::std::marker::Sync + 'mock, { let mut closure = self.closure.lock().unwrap(); *closure = ::std::boxed::Box::new(move || ::std::result::Result::Err(exception.clone().into())); } } pub struct interact<'mock> { pub(crate) closure: ::std::sync::Mutex<::std::boxed::Box< dyn ::std::ops::FnMut(::std::primitive::i32) -> ::std::result::Result< (), ::::errors::factories::InteractError, > + ::std::marker::Send + ::std::marker::Sync + 'mock, >>, } #[allow(clippy::redundant_closure)] impl<'mock> interact<'mock> { pub(crate) fn unimplemented() -> Self { Self { closure: ::std::sync::Mutex::new(::std::boxed::Box::new(|_: ::std::primitive::i32| panic!( "{}::{} is not mocked", "Factories", "interact", ))), } } pub fn ret(&self, value: ()) { self.mock(move |_: ::std::primitive::i32| value.clone()); } pub fn mock(&self, mut mock: impl ::std::ops::FnMut(::std::primitive::i32) -> () + ::std::marker::Send + ::std::marker::Sync + 'mock) { let mut closure = self.closure.lock().unwrap(); *closure = ::std::boxed::Box::new(move |arg| ::std::result::Result::Ok(mock(arg))); } pub fn mock_result(&self, mut mock: impl ::std::ops::FnMut(::std::primitive::i32) -> ::std::result::Result<(), ::::errors::factories::InteractError> + ::std::marker::Send + ::std::marker::Sync + 'mock) { let mut closure = self.closure.lock().unwrap(); *closure = ::std::boxed::Box::new(move |arg| mock(arg)); } pub fn throw(&self, exception: E) where E: ::std::convert::Into<::::errors::factories::InteractError>, E: ::std::clone::Clone + ::std::marker::Send + ::std::marker::Sync + 'mock, { let mut closure = self.closure.lock().unwrap(); *closure = ::std::boxed::Box::new(move |_: ::std::primitive::i32| ::std::result::Result::Err(exception.clone().into())); } } pub struct interactFast<'mock> { pub(crate) closure: ::std::sync::Mutex<::std::boxed::Box< dyn ::std::ops::FnMut() -> ::std::result::Result< ::std::primitive::i32, ::::errors::factories::InteractFastError, > + ::std::marker::Send + ::std::marker::Sync + 'mock, >>, } #[allow(clippy::redundant_closure)] impl<'mock> interactFast<'mock> { pub(crate) fn unimplemented() -> Self { Self { closure: ::std::sync::Mutex::new(::std::boxed::Box::new(|| panic!( "{}::{} is not mocked", "Factories", "interactFast", ))), } } pub fn ret(&self, value: ::std::primitive::i32) { self.mock(move || value.clone()); } pub fn mock(&self, mut mock: impl ::std::ops::FnMut() -> ::std::primitive::i32 + ::std::marker::Send + ::std::marker::Sync + 'mock) { let mut closure = self.closure.lock().unwrap(); *closure = ::std::boxed::Box::new(move || ::std::result::Result::Ok(mock())); } pub fn mock_result(&self, mut mock: impl ::std::ops::FnMut() -> ::std::result::Result<::std::primitive::i32, ::::errors::factories::InteractFastError> + ::std::marker::Send + ::std::marker::Sync + 'mock) { let mut closure = self.closure.lock().unwrap(); *closure = ::std::boxed::Box::new(move || mock()); } pub fn throw(&self, exception: E) where E: ::std::convert::Into<::::errors::factories::InteractFastError>, E: ::std::clone::Clone + ::std::marker::Send + ::std::marker::Sync + 'mock, { let mut closure = self.closure.lock().unwrap(); *closure = ::std::boxed::Box::new(move || ::std::result::Result::Err(exception.clone().into())); } } pub struct serialize<'mock> { pub(crate) closure: ::std::sync::Mutex<::std::boxed::Box< dyn ::std::ops::FnMut() -> ::std::result::Result< (::std::primitive::i32, ::futures::stream::BoxStream<'static, ::std::result::Result<::std::primitive::i32, crate::errors::factories::SerializeStreamError>>), ::::errors::factories::SerializeError, > + ::std::marker::Send + ::std::marker::Sync + 'mock, >>, } #[allow(clippy::redundant_closure)] impl<'mock> serialize<'mock> { pub(crate) fn unimplemented() -> Self { Self { closure: ::std::sync::Mutex::new(::std::boxed::Box::new(|| panic!( "{}::{} is not mocked", "Factories", "serialize", ))), } } pub fn ret(&self, _value: (::std::primitive::i32, ::futures::stream::BoxStream<'static, ::std::result::Result<::std::primitive::i32, crate::errors::factories::SerializeStreamError>>)) { unimplemented!("Mocking streams is not yet implemented, as value isn't cloneable") } pub fn mock(&self, mut mock: impl ::std::ops::FnMut() -> (::std::primitive::i32, ::futures::stream::BoxStream<'static, ::std::result::Result<::std::primitive::i32, crate::errors::factories::SerializeStreamError>>) + ::std::marker::Send + ::std::marker::Sync + 'mock) { let mut closure = self.closure.lock().unwrap(); *closure = ::std::boxed::Box::new(move || ::std::result::Result::Ok(mock())); } pub fn mock_result(&self, mut mock: impl ::std::ops::FnMut() -> ::std::result::Result<(::std::primitive::i32, ::futures::stream::BoxStream<'static, ::std::result::Result<::std::primitive::i32, crate::errors::factories::SerializeStreamError>>), ::::errors::factories::SerializeError> + ::std::marker::Send + ::std::marker::Sync + 'mock) { let mut closure = self.closure.lock().unwrap(); *closure = ::std::boxed::Box::new(move || mock()); } pub fn throw(&self, exception: E) where E: ::std::convert::Into<::::errors::factories::SerializeError>, E: ::std::clone::Clone + ::std::marker::Send + ::std::marker::Sync + 'mock, { let mut closure = self.closure.lock().unwrap(); *closure = ::std::boxed::Box::new(move || ::std::result::Result::Err(exception.clone().into())); } } } pub mod perform { pub struct foo<'mock> { pub(crate) closure: ::std::sync::Mutex<::std::boxed::Box< dyn ::std::ops::FnMut() -> ::std::result::Result< (), ::::errors::perform::FooError, > + ::std::marker::Send + ::std::marker::Sync + 'mock, >>, } #[allow(clippy::redundant_closure)] impl<'mock> foo<'mock> { pub(crate) fn unimplemented() -> Self { Self { closure: ::std::sync::Mutex::new(::std::boxed::Box::new(|| panic!( "{}::{} is not mocked", "Perform", "foo", ))), } } pub fn ret(&self, value: ()) { self.mock(move || value.clone()); } pub fn mock(&self, mut mock: impl ::std::ops::FnMut() -> () + ::std::marker::Send + ::std::marker::Sync + 'mock) { let mut closure = self.closure.lock().unwrap(); *closure = ::std::boxed::Box::new(move || ::std::result::Result::Ok(mock())); } pub fn mock_result(&self, mut mock: impl ::std::ops::FnMut() -> ::std::result::Result<(), ::::errors::perform::FooError> + ::std::marker::Send + ::std::marker::Sync + 'mock) { let mut closure = self.closure.lock().unwrap(); *closure = ::std::boxed::Box::new(move || mock()); } pub fn throw(&self, exception: E) where E: ::std::convert::Into<::::errors::perform::FooError>, E: ::std::clone::Clone + ::std::marker::Send + ::std::marker::Sync + 'mock, { let mut closure = self.closure.lock().unwrap(); *closure = ::std::boxed::Box::new(move || ::std::result::Result::Err(exception.clone().into())); } } } pub mod interact_with_shared { pub struct do_some_similar_things<'mock> { pub(crate) closure: ::std::sync::Mutex<::std::boxed::Box< dyn ::std::ops::FnMut() -> ::std::result::Result< shared__types::DoSomethingResult, ::::errors::interact_with_shared::DoSomeSimilarThingsError, > + ::std::marker::Send + ::std::marker::Sync + 'mock, >>, } #[allow(clippy::redundant_closure)] impl<'mock> do_some_similar_things<'mock> { pub(crate) fn unimplemented() -> Self { Self { closure: ::std::sync::Mutex::new(::std::boxed::Box::new(|| panic!( "{}::{} is not mocked", "InteractWithShared", "do_some_similar_things", ))), } } pub fn ret(&self, value: shared__types::DoSomethingResult) { self.mock(move || value.clone()); } pub fn mock(&self, mut mock: impl ::std::ops::FnMut() -> shared__types::DoSomethingResult + ::std::marker::Send + ::std::marker::Sync + 'mock) { let mut closure = self.closure.lock().unwrap(); *closure = ::std::boxed::Box::new(move || ::std::result::Result::Ok(mock())); } pub fn mock_result(&self, mut mock: impl ::std::ops::FnMut() -> ::std::result::Result + ::std::marker::Send + ::std::marker::Sync + 'mock) { let mut closure = self.closure.lock().unwrap(); *closure = ::std::boxed::Box::new(move || mock()); } pub fn throw(&self, exception: E) where E: ::std::convert::Into<::::errors::interact_with_shared::DoSomeSimilarThingsError>, E: ::std::clone::Clone + ::std::marker::Send + ::std::marker::Sync + 'mock, { let mut closure = self.closure.lock().unwrap(); *closure = ::std::boxed::Box::new(move || ::std::result::Result::Err(exception.clone().into())); } } } }