// @generated by Thrift for thrift/compiler/test/fixtures/basic/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 FooService<'mock> { pub simple_rpc: r#impl::foo_service::simple_rpc<'mock>, _marker: ::std::marker::PhantomData<&'mock ()>, } impl crate::DynClient for dyn ::::FooService { type Mock<'mock> = FooService<'mock>; fn mock<'mock>() -> Self::Mock<'mock> { FooService { simple_rpc: r#impl::foo_service::simple_rpc::unimplemented(), _marker: ::std::marker::PhantomData, } } } impl<'mock> ::::FooService for FooService<'mock> { fn simple_rpc( &self, ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<(), crate::errors::foo_service::SimpleRpcError>> { let mut closure = self.simple_rpc.closure.lock().unwrap(); let closure: &mut dyn ::std::ops::FnMut() -> _ = &mut **closure; ::std::boxed::Box::pin(::futures::future::ready(closure())) } } impl<'mock, T> ::::FooServiceExt for FooService<'mock> where T: ::fbthrift::Transport, { fn simple_rpc_with_rpc_opts( &self, _rpc_options: T::RpcOptions, ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<(), crate::errors::foo_service::SimpleRpcError>> { ::simple_rpc( self, ) } fn transport(&self) -> &T { ::fbthrift::help::GetTransport::transport(self) } } impl<'mock, T> ::fbthrift::help::GetTransport for FooService<'mock> where T: ::fbthrift::Transport, { fn transport(&self) -> &T { unimplemented!("FooServiceExt::transport is not implemented for mock client") } } pub struct FB303Service<'mock> { pub simple_rpc: r#impl::f_b303_service::simple_rpc<'mock>, _marker: ::std::marker::PhantomData<&'mock ()>, } impl crate::DynClient for dyn ::::FB303Service { type Mock<'mock> = FB303Service<'mock>; fn mock<'mock>() -> Self::Mock<'mock> { FB303Service { simple_rpc: r#impl::f_b303_service::simple_rpc::unimplemented(), _marker: ::std::marker::PhantomData, } } } impl<'mock> ::::FB303Service for FB303Service<'mock> { fn simple_rpc( &self, arg_int_parameter: ::std::primitive::i32, ) -> ::futures::future::BoxFuture<'static, ::std::result::Result> { let mut closure = self.simple_rpc.closure.lock().unwrap(); let closure: &mut dyn ::std::ops::FnMut(::std::primitive::i32) -> _ = &mut **closure; ::std::boxed::Box::pin(::futures::future::ready(closure(arg_int_parameter.clone()))) } } impl<'mock, T> ::::FB303ServiceExt for FB303Service<'mock> where T: ::fbthrift::Transport, { fn simple_rpc_with_rpc_opts( &self, arg_int_parameter: ::std::primitive::i32, _rpc_options: T::RpcOptions, ) -> ::futures::future::BoxFuture<'static, ::std::result::Result> { ::simple_rpc( self, arg_int_parameter, ) } fn transport(&self) -> &T { ::fbthrift::help::GetTransport::transport(self) } } impl<'mock, T> ::fbthrift::help::GetTransport for FB303Service<'mock> where T: ::fbthrift::Transport, { fn transport(&self) -> &T { unimplemented!("FB303ServiceExt::transport is not implemented for mock client") } } pub struct MyService<'mock> { pub ping: r#impl::my_service::ping<'mock>, pub getRandomData: r#impl::my_service::getRandomData<'mock>, pub sink: r#impl::my_service::sink<'mock>, pub putDataById: r#impl::my_service::putDataById<'mock>, pub hasDataById: r#impl::my_service::hasDataById<'mock>, pub getDataById: r#impl::my_service::getDataById<'mock>, pub deleteDataById: r#impl::my_service::deleteDataById<'mock>, pub lobDataById: r#impl::my_service::lobDataById<'mock>, pub invalid_return_for_hack: r#impl::my_service::invalid_return_for_hack<'mock>, pub rpc_skipped_codegen: r#impl::my_service::rpc_skipped_codegen<'mock>, _marker: ::std::marker::PhantomData<&'mock ()>, } impl crate::DynClient for dyn ::::MyService { type Mock<'mock> = MyService<'mock>; fn mock<'mock>() -> Self::Mock<'mock> { MyService { ping: r#impl::my_service::ping::unimplemented(), getRandomData: r#impl::my_service::getRandomData::unimplemented(), sink: r#impl::my_service::sink::unimplemented(), putDataById: r#impl::my_service::putDataById::unimplemented(), hasDataById: r#impl::my_service::hasDataById::unimplemented(), getDataById: r#impl::my_service::getDataById::unimplemented(), deleteDataById: r#impl::my_service::deleteDataById::unimplemented(), lobDataById: r#impl::my_service::lobDataById::unimplemented(), invalid_return_for_hack: r#impl::my_service::invalid_return_for_hack::unimplemented(), rpc_skipped_codegen: r#impl::my_service::rpc_skipped_codegen::unimplemented(), _marker: ::std::marker::PhantomData, } } } impl<'mock> ::::MyService for MyService<'mock> { fn ping( &self, ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<(), crate::errors::my_service::PingError>> { let mut closure = self.ping.closure.lock().unwrap(); let closure: &mut dyn ::std::ops::FnMut() -> _ = &mut **closure; ::std::boxed::Box::pin(::futures::future::ready(closure())) } fn getRandomData( &self, ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<::std::string::String, crate::errors::my_service::GetRandomDataError>> { let mut closure = self.getRandomData.closure.lock().unwrap(); let closure: &mut dyn ::std::ops::FnMut() -> _ = &mut **closure; ::std::boxed::Box::pin(::futures::future::ready(closure())) } fn sink( &self, arg_sink: ::std::primitive::i64, ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<(), crate::errors::my_service::SinkError>> { let mut closure = self.sink.closure.lock().unwrap(); let closure: &mut dyn ::std::ops::FnMut(::std::primitive::i64) -> _ = &mut **closure; ::std::boxed::Box::pin(::futures::future::ready(closure(arg_sink.clone()))) } fn putDataById( &self, arg_id: ::std::primitive::i64, arg_data: &::std::primitive::str, ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<(), crate::errors::my_service::PutDataByIdError>> { let mut closure = self.putDataById.closure.lock().unwrap(); let closure: &mut dyn ::std::ops::FnMut(::std::primitive::i64, ::std::string::String) -> _ = &mut **closure; ::std::boxed::Box::pin(::futures::future::ready(closure(arg_id.clone(), arg_data.to_owned()))) } fn hasDataById( &self, arg_id: ::std::primitive::i64, ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<::std::primitive::bool, crate::errors::my_service::HasDataByIdError>> { let mut closure = self.hasDataById.closure.lock().unwrap(); let closure: &mut dyn ::std::ops::FnMut(::std::primitive::i64) -> _ = &mut **closure; ::std::boxed::Box::pin(::futures::future::ready(closure(arg_id.clone()))) } fn getDataById( &self, arg_id: ::std::primitive::i64, ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<::std::string::String, crate::errors::my_service::GetDataByIdError>> { let mut closure = self.getDataById.closure.lock().unwrap(); let closure: &mut dyn ::std::ops::FnMut(::std::primitive::i64) -> _ = &mut **closure; ::std::boxed::Box::pin(::futures::future::ready(closure(arg_id.clone()))) } fn deleteDataById( &self, arg_id: ::std::primitive::i64, ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<(), crate::errors::my_service::DeleteDataByIdError>> { let mut closure = self.deleteDataById.closure.lock().unwrap(); let closure: &mut dyn ::std::ops::FnMut(::std::primitive::i64) -> _ = &mut **closure; ::std::boxed::Box::pin(::futures::future::ready(closure(arg_id.clone()))) } fn lobDataById( &self, arg_id: ::std::primitive::i64, arg_data: &::std::primitive::str, ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<(), crate::errors::my_service::LobDataByIdError>> { let mut closure = self.lobDataById.closure.lock().unwrap(); let closure: &mut dyn ::std::ops::FnMut(::std::primitive::i64, ::std::string::String) -> _ = &mut **closure; ::std::boxed::Box::pin(::futures::future::ready(closure(arg_id.clone(), arg_data.to_owned()))) } fn invalid_return_for_hack( &self, ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<::std::collections::BTreeSet<::fbthrift::export::OrderedFloat<::std::primitive::f32>>, crate::errors::my_service::InvalidReturnForHackError>> { let mut closure = self.invalid_return_for_hack.closure.lock().unwrap(); let closure: &mut dyn ::std::ops::FnMut() -> _ = &mut **closure; ::std::boxed::Box::pin(::futures::future::ready(closure())) } fn rpc_skipped_codegen( &self, ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<(), crate::errors::my_service::RpcSkippedCodegenError>> { let mut closure = self.rpc_skipped_codegen.closure.lock().unwrap(); let closure: &mut dyn ::std::ops::FnMut() -> _ = &mut **closure; ::std::boxed::Box::pin(::futures::future::ready(closure())) } } impl<'mock, T> ::::MyServiceExt for MyService<'mock> where T: ::fbthrift::Transport, { fn ping_with_rpc_opts( &self, _rpc_options: T::RpcOptions, ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<(), crate::errors::my_service::PingError>> { ::ping( self, ) } fn getRandomData_with_rpc_opts( &self, _rpc_options: T::RpcOptions, ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<::std::string::String, crate::errors::my_service::GetRandomDataError>> { ::getRandomData( self, ) } fn sink_with_rpc_opts( &self, arg_sink: ::std::primitive::i64, _rpc_options: T::RpcOptions, ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<(), crate::errors::my_service::SinkError>> { ::sink( self, arg_sink, ) } fn putDataById_with_rpc_opts( &self, arg_id: ::std::primitive::i64, arg_data: &::std::primitive::str, _rpc_options: T::RpcOptions, ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<(), crate::errors::my_service::PutDataByIdError>> { ::putDataById( self, arg_id, arg_data, ) } fn hasDataById_with_rpc_opts( &self, arg_id: ::std::primitive::i64, _rpc_options: T::RpcOptions, ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<::std::primitive::bool, crate::errors::my_service::HasDataByIdError>> { ::hasDataById( self, arg_id, ) } fn getDataById_with_rpc_opts( &self, arg_id: ::std::primitive::i64, _rpc_options: T::RpcOptions, ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<::std::string::String, crate::errors::my_service::GetDataByIdError>> { ::getDataById( self, arg_id, ) } fn deleteDataById_with_rpc_opts( &self, arg_id: ::std::primitive::i64, _rpc_options: T::RpcOptions, ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<(), crate::errors::my_service::DeleteDataByIdError>> { ::deleteDataById( self, arg_id, ) } fn lobDataById_with_rpc_opts( &self, arg_id: ::std::primitive::i64, arg_data: &::std::primitive::str, _rpc_options: T::RpcOptions, ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<(), crate::errors::my_service::LobDataByIdError>> { ::lobDataById( self, arg_id, arg_data, ) } fn invalid_return_for_hack_with_rpc_opts( &self, _rpc_options: T::RpcOptions, ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<::std::collections::BTreeSet<::fbthrift::export::OrderedFloat<::std::primitive::f32>>, crate::errors::my_service::InvalidReturnForHackError>> { ::invalid_return_for_hack( self, ) } fn rpc_skipped_codegen_with_rpc_opts( &self, _rpc_options: T::RpcOptions, ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<(), crate::errors::my_service::RpcSkippedCodegenError>> { ::rpc_skipped_codegen( 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 DbMixedStackArguments<'mock> { pub getDataByKey0: r#impl::db_mixed_stack_arguments::getDataByKey0<'mock>, pub getDataByKey1: r#impl::db_mixed_stack_arguments::getDataByKey1<'mock>, _marker: ::std::marker::PhantomData<&'mock ()>, } impl crate::DynClient for dyn ::::DbMixedStackArguments { type Mock<'mock> = DbMixedStackArguments<'mock>; fn mock<'mock>() -> Self::Mock<'mock> { DbMixedStackArguments { getDataByKey0: r#impl::db_mixed_stack_arguments::getDataByKey0::unimplemented(), getDataByKey1: r#impl::db_mixed_stack_arguments::getDataByKey1::unimplemented(), _marker: ::std::marker::PhantomData, } } } impl<'mock> ::::DbMixedStackArguments for DbMixedStackArguments<'mock> { fn getDataByKey0( &self, arg_key: &::std::primitive::str, ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<::std::vec::Vec<::std::primitive::u8>, crate::errors::db_mixed_stack_arguments::GetDataByKey0Error>> { let mut closure = self.getDataByKey0.closure.lock().unwrap(); let closure: &mut dyn ::std::ops::FnMut(::std::string::String) -> _ = &mut **closure; ::std::boxed::Box::pin(::futures::future::ready(closure(arg_key.to_owned()))) } fn getDataByKey1( &self, arg_key: &::std::primitive::str, ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<::std::vec::Vec<::std::primitive::u8>, crate::errors::db_mixed_stack_arguments::GetDataByKey1Error>> { let mut closure = self.getDataByKey1.closure.lock().unwrap(); let closure: &mut dyn ::std::ops::FnMut(::std::string::String) -> _ = &mut **closure; ::std::boxed::Box::pin(::futures::future::ready(closure(arg_key.to_owned()))) } } impl<'mock, T> ::::DbMixedStackArgumentsExt for DbMixedStackArguments<'mock> where T: ::fbthrift::Transport, { fn getDataByKey0_with_rpc_opts( &self, arg_key: &::std::primitive::str, _rpc_options: T::RpcOptions, ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<::std::vec::Vec<::std::primitive::u8>, crate::errors::db_mixed_stack_arguments::GetDataByKey0Error>> { ::getDataByKey0( self, arg_key, ) } fn getDataByKey1_with_rpc_opts( &self, arg_key: &::std::primitive::str, _rpc_options: T::RpcOptions, ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<::std::vec::Vec<::std::primitive::u8>, crate::errors::db_mixed_stack_arguments::GetDataByKey1Error>> { ::getDataByKey1( self, arg_key, ) } fn transport(&self) -> &T { ::fbthrift::help::GetTransport::transport(self) } } impl<'mock, T> ::fbthrift::help::GetTransport for DbMixedStackArguments<'mock> where T: ::fbthrift::Transport, { fn transport(&self) -> &T { unimplemented!("DbMixedStackArgumentsExt::transport is not implemented for mock client") } } pub mod r#impl { pub mod foo_service { pub struct simple_rpc<'mock> { pub(crate) closure: ::std::sync::Mutex<::std::boxed::Box< dyn ::std::ops::FnMut() -> ::std::result::Result< (), ::::errors::foo_service::SimpleRpcError, > + ::std::marker::Send + ::std::marker::Sync + 'mock, >>, } #[allow(clippy::redundant_closure)] impl<'mock> simple_rpc<'mock> { pub(crate) fn unimplemented() -> Self { Self { closure: ::std::sync::Mutex::new(::std::boxed::Box::new(|| panic!( "{}::{} is not mocked", "FooService", "simple_rpc", ))), } } 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::foo_service::SimpleRpcError> + ::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::foo_service::SimpleRpcError>, 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 f_b303_service { pub struct simple_rpc<'mock> { pub(crate) closure: ::std::sync::Mutex<::std::boxed::Box< dyn ::std::ops::FnMut(::std::primitive::i32) -> ::std::result::Result< crate::types::ReservedKeyword, ::::errors::f_b303_service::SimpleRpcError, > + ::std::marker::Send + ::std::marker::Sync + 'mock, >>, } #[allow(clippy::redundant_closure)] impl<'mock> simple_rpc<'mock> { pub(crate) fn unimplemented() -> Self { Self { closure: ::std::sync::Mutex::new(::std::boxed::Box::new(|_: ::std::primitive::i32| panic!( "{}::{} is not mocked", "FB303Service", "simple_rpc", ))), } } pub fn ret(&self, value: crate::types::ReservedKeyword) { self.mock(move |_: ::std::primitive::i32| value.clone()); } pub fn mock(&self, mut mock: impl ::std::ops::FnMut(::std::primitive::i32) -> crate::types::ReservedKeyword + ::std::marker::Send + ::std::marker::Sync + 'mock) { let mut closure = self.closure.lock().unwrap(); *closure = ::std::boxed::Box::new(move |int_parameter| ::std::result::Result::Ok(mock(int_parameter))); } pub fn mock_result(&self, mut mock: impl ::std::ops::FnMut(::std::primitive::i32) -> ::std::result::Result + ::std::marker::Send + ::std::marker::Sync + 'mock) { let mut closure = self.closure.lock().unwrap(); *closure = ::std::boxed::Box::new(move |int_parameter| mock(int_parameter)); } pub fn throw(&self, exception: E) where E: ::std::convert::Into<::::errors::f_b303_service::SimpleRpcError>, 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 mod my_service { pub struct ping<'mock> { pub(crate) closure: ::std::sync::Mutex<::std::boxed::Box< dyn ::std::ops::FnMut() -> ::std::result::Result< (), ::::errors::my_service::PingError, > + ::std::marker::Send + ::std::marker::Sync + 'mock, >>, } #[allow(clippy::redundant_closure)] impl<'mock> ping<'mock> { pub(crate) fn unimplemented() -> Self { Self { closure: ::std::sync::Mutex::new(::std::boxed::Box::new(|| panic!( "{}::{} is not mocked", "MyService", "ping", ))), } } 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::PingError> + ::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::PingError>, 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 getRandomData<'mock> { pub(crate) closure: ::std::sync::Mutex<::std::boxed::Box< dyn ::std::ops::FnMut() -> ::std::result::Result< ::std::string::String, ::::errors::my_service::GetRandomDataError, > + ::std::marker::Send + ::std::marker::Sync + 'mock, >>, } #[allow(clippy::redundant_closure)] impl<'mock> getRandomData<'mock> { pub(crate) fn unimplemented() -> Self { Self { closure: ::std::sync::Mutex::new(::std::boxed::Box::new(|| panic!( "{}::{} is not mocked", "MyService", "getRandomData", ))), } } pub fn ret(&self, value: ::std::string::String) { self.mock(move || value.clone()); } pub fn mock(&self, mut mock: impl ::std::ops::FnMut() -> ::std::string::String + ::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::string::String, ::::errors::my_service::GetRandomDataError> + ::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::GetRandomDataError>, 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 sink<'mock> { pub(crate) closure: ::std::sync::Mutex<::std::boxed::Box< dyn ::std::ops::FnMut(::std::primitive::i64) -> ::std::result::Result< (), ::::errors::my_service::SinkError, > + ::std::marker::Send + ::std::marker::Sync + 'mock, >>, } #[allow(clippy::redundant_closure)] impl<'mock> sink<'mock> { pub(crate) fn unimplemented() -> Self { Self { closure: ::std::sync::Mutex::new(::std::boxed::Box::new(|_: ::std::primitive::i64| panic!( "{}::{} is not mocked", "MyService", "sink", ))), } } pub fn ret(&self, value: ()) { self.mock(move |_: ::std::primitive::i64| value.clone()); } pub fn mock(&self, mut mock: impl ::std::ops::FnMut(::std::primitive::i64) -> () + ::std::marker::Send + ::std::marker::Sync + 'mock) { let mut closure = self.closure.lock().unwrap(); *closure = ::std::boxed::Box::new(move |sink| ::std::result::Result::Ok(mock(sink))); } pub fn mock_result(&self, mut mock: impl ::std::ops::FnMut(::std::primitive::i64) -> ::std::result::Result<(), ::::errors::my_service::SinkError> + ::std::marker::Send + ::std::marker::Sync + 'mock) { let mut closure = self.closure.lock().unwrap(); *closure = ::std::boxed::Box::new(move |sink| mock(sink)); } pub fn throw(&self, exception: E) where E: ::std::convert::Into<::::errors::my_service::SinkError>, 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::i64| ::std::result::Result::Err(exception.clone().into())); } } pub struct putDataById<'mock> { pub(crate) closure: ::std::sync::Mutex<::std::boxed::Box< dyn ::std::ops::FnMut(::std::primitive::i64, ::std::string::String) -> ::std::result::Result< (), ::::errors::my_service::PutDataByIdError, > + ::std::marker::Send + ::std::marker::Sync + 'mock, >>, } #[allow(clippy::redundant_closure)] impl<'mock> putDataById<'mock> { pub(crate) fn unimplemented() -> Self { Self { closure: ::std::sync::Mutex::new(::std::boxed::Box::new(|_: ::std::primitive::i64, _: ::std::string::String| panic!( "{}::{} is not mocked", "MyService", "putDataById", ))), } } pub fn ret(&self, value: ()) { self.mock(move |_: ::std::primitive::i64, _: ::std::string::String| value.clone()); } pub fn mock(&self, mut mock: impl ::std::ops::FnMut(::std::primitive::i64, ::std::string::String) -> () + ::std::marker::Send + ::std::marker::Sync + 'mock) { let mut closure = self.closure.lock().unwrap(); *closure = ::std::boxed::Box::new(move |id, data| ::std::result::Result::Ok(mock(id, data))); } pub fn mock_result(&self, mut mock: impl ::std::ops::FnMut(::std::primitive::i64, ::std::string::String) -> ::std::result::Result<(), ::::errors::my_service::PutDataByIdError> + ::std::marker::Send + ::std::marker::Sync + 'mock) { let mut closure = self.closure.lock().unwrap(); *closure = ::std::boxed::Box::new(move |id, data| mock(id, data)); } pub fn throw(&self, exception: E) where E: ::std::convert::Into<::::errors::my_service::PutDataByIdError>, 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::i64, _: ::std::string::String| ::std::result::Result::Err(exception.clone().into())); } } pub struct hasDataById<'mock> { pub(crate) closure: ::std::sync::Mutex<::std::boxed::Box< dyn ::std::ops::FnMut(::std::primitive::i64) -> ::std::result::Result< ::std::primitive::bool, ::::errors::my_service::HasDataByIdError, > + ::std::marker::Send + ::std::marker::Sync + 'mock, >>, } #[allow(clippy::redundant_closure)] impl<'mock> hasDataById<'mock> { pub(crate) fn unimplemented() -> Self { Self { closure: ::std::sync::Mutex::new(::std::boxed::Box::new(|_: ::std::primitive::i64| panic!( "{}::{} is not mocked", "MyService", "hasDataById", ))), } } pub fn ret(&self, value: ::std::primitive::bool) { self.mock(move |_: ::std::primitive::i64| value.clone()); } pub fn mock(&self, mut mock: impl ::std::ops::FnMut(::std::primitive::i64) -> ::std::primitive::bool + ::std::marker::Send + ::std::marker::Sync + 'mock) { let mut closure = self.closure.lock().unwrap(); *closure = ::std::boxed::Box::new(move |id| ::std::result::Result::Ok(mock(id))); } pub fn mock_result(&self, mut mock: impl ::std::ops::FnMut(::std::primitive::i64) -> ::std::result::Result<::std::primitive::bool, ::::errors::my_service::HasDataByIdError> + ::std::marker::Send + ::std::marker::Sync + 'mock) { let mut closure = self.closure.lock().unwrap(); *closure = ::std::boxed::Box::new(move |id| mock(id)); } pub fn throw(&self, exception: E) where E: ::std::convert::Into<::::errors::my_service::HasDataByIdError>, 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::i64| ::std::result::Result::Err(exception.clone().into())); } } pub struct getDataById<'mock> { pub(crate) closure: ::std::sync::Mutex<::std::boxed::Box< dyn ::std::ops::FnMut(::std::primitive::i64) -> ::std::result::Result< ::std::string::String, ::::errors::my_service::GetDataByIdError, > + ::std::marker::Send + ::std::marker::Sync + 'mock, >>, } #[allow(clippy::redundant_closure)] impl<'mock> getDataById<'mock> { pub(crate) fn unimplemented() -> Self { Self { closure: ::std::sync::Mutex::new(::std::boxed::Box::new(|_: ::std::primitive::i64| panic!( "{}::{} is not mocked", "MyService", "getDataById", ))), } } pub fn ret(&self, value: ::std::string::String) { self.mock(move |_: ::std::primitive::i64| value.clone()); } pub fn mock(&self, mut mock: impl ::std::ops::FnMut(::std::primitive::i64) -> ::std::string::String + ::std::marker::Send + ::std::marker::Sync + 'mock) { let mut closure = self.closure.lock().unwrap(); *closure = ::std::boxed::Box::new(move |id| ::std::result::Result::Ok(mock(id))); } pub fn mock_result(&self, mut mock: impl ::std::ops::FnMut(::std::primitive::i64) -> ::std::result::Result<::std::string::String, ::::errors::my_service::GetDataByIdError> + ::std::marker::Send + ::std::marker::Sync + 'mock) { let mut closure = self.closure.lock().unwrap(); *closure = ::std::boxed::Box::new(move |id| mock(id)); } pub fn throw(&self, exception: E) where E: ::std::convert::Into<::::errors::my_service::GetDataByIdError>, 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::i64| ::std::result::Result::Err(exception.clone().into())); } } pub struct deleteDataById<'mock> { pub(crate) closure: ::std::sync::Mutex<::std::boxed::Box< dyn ::std::ops::FnMut(::std::primitive::i64) -> ::std::result::Result< (), ::::errors::my_service::DeleteDataByIdError, > + ::std::marker::Send + ::std::marker::Sync + 'mock, >>, } #[allow(clippy::redundant_closure)] impl<'mock> deleteDataById<'mock> { pub(crate) fn unimplemented() -> Self { Self { closure: ::std::sync::Mutex::new(::std::boxed::Box::new(|_: ::std::primitive::i64| panic!( "{}::{} is not mocked", "MyService", "deleteDataById", ))), } } pub fn ret(&self, value: ()) { self.mock(move |_: ::std::primitive::i64| value.clone()); } pub fn mock(&self, mut mock: impl ::std::ops::FnMut(::std::primitive::i64) -> () + ::std::marker::Send + ::std::marker::Sync + 'mock) { let mut closure = self.closure.lock().unwrap(); *closure = ::std::boxed::Box::new(move |id| ::std::result::Result::Ok(mock(id))); } pub fn mock_result(&self, mut mock: impl ::std::ops::FnMut(::std::primitive::i64) -> ::std::result::Result<(), ::::errors::my_service::DeleteDataByIdError> + ::std::marker::Send + ::std::marker::Sync + 'mock) { let mut closure = self.closure.lock().unwrap(); *closure = ::std::boxed::Box::new(move |id| mock(id)); } pub fn throw(&self, exception: E) where E: ::std::convert::Into<::::errors::my_service::DeleteDataByIdError>, 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::i64| ::std::result::Result::Err(exception.clone().into())); } } pub struct lobDataById<'mock> { pub(crate) closure: ::std::sync::Mutex<::std::boxed::Box< dyn ::std::ops::FnMut(::std::primitive::i64, ::std::string::String) -> ::std::result::Result< (), ::::errors::my_service::LobDataByIdError, > + ::std::marker::Send + ::std::marker::Sync + 'mock, >>, } #[allow(clippy::redundant_closure)] impl<'mock> lobDataById<'mock> { pub(crate) fn unimplemented() -> Self { Self { closure: ::std::sync::Mutex::new(::std::boxed::Box::new(|_: ::std::primitive::i64, _: ::std::string::String| panic!( "{}::{} is not mocked", "MyService", "lobDataById", ))), } } pub fn ret(&self, value: ()) { self.mock(move |_: ::std::primitive::i64, _: ::std::string::String| value.clone()); } pub fn mock(&self, mut mock: impl ::std::ops::FnMut(::std::primitive::i64, ::std::string::String) -> () + ::std::marker::Send + ::std::marker::Sync + 'mock) { let mut closure = self.closure.lock().unwrap(); *closure = ::std::boxed::Box::new(move |id, data| ::std::result::Result::Ok(mock(id, data))); } pub fn mock_result(&self, mut mock: impl ::std::ops::FnMut(::std::primitive::i64, ::std::string::String) -> ::std::result::Result<(), ::::errors::my_service::LobDataByIdError> + ::std::marker::Send + ::std::marker::Sync + 'mock) { let mut closure = self.closure.lock().unwrap(); *closure = ::std::boxed::Box::new(move |id, data| mock(id, data)); } pub fn throw(&self, exception: E) where E: ::std::convert::Into<::::errors::my_service::LobDataByIdError>, 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::i64, _: ::std::string::String| ::std::result::Result::Err(exception.clone().into())); } } pub struct invalid_return_for_hack<'mock> { pub(crate) closure: ::std::sync::Mutex<::std::boxed::Box< dyn ::std::ops::FnMut() -> ::std::result::Result< ::std::collections::BTreeSet<::fbthrift::export::OrderedFloat<::std::primitive::f32>>, ::::errors::my_service::InvalidReturnForHackError, > + ::std::marker::Send + ::std::marker::Sync + 'mock, >>, } #[allow(clippy::redundant_closure)] impl<'mock> invalid_return_for_hack<'mock> { pub(crate) fn unimplemented() -> Self { Self { closure: ::std::sync::Mutex::new(::std::boxed::Box::new(|| panic!( "{}::{} is not mocked", "MyService", "invalid_return_for_hack", ))), } } pub fn ret(&self, value: ::std::collections::BTreeSet<::fbthrift::export::OrderedFloat<::std::primitive::f32>>) { self.mock(move || value.clone()); } pub fn mock(&self, mut mock: impl ::std::ops::FnMut() -> ::std::collections::BTreeSet<::fbthrift::export::OrderedFloat<::std::primitive::f32>> + ::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::collections::BTreeSet<::fbthrift::export::OrderedFloat<::std::primitive::f32>>, ::::errors::my_service::InvalidReturnForHackError> + ::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::InvalidReturnForHackError>, 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 rpc_skipped_codegen<'mock> { pub(crate) closure: ::std::sync::Mutex<::std::boxed::Box< dyn ::std::ops::FnMut() -> ::std::result::Result< (), ::::errors::my_service::RpcSkippedCodegenError, > + ::std::marker::Send + ::std::marker::Sync + 'mock, >>, } #[allow(clippy::redundant_closure)] impl<'mock> rpc_skipped_codegen<'mock> { pub(crate) fn unimplemented() -> Self { Self { closure: ::std::sync::Mutex::new(::std::boxed::Box::new(|| panic!( "{}::{} is not mocked", "MyService", "rpc_skipped_codegen", ))), } } 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::RpcSkippedCodegenError> + ::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::RpcSkippedCodegenError>, 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 db_mixed_stack_arguments { pub struct getDataByKey0<'mock> { pub(crate) closure: ::std::sync::Mutex<::std::boxed::Box< dyn ::std::ops::FnMut(::std::string::String) -> ::std::result::Result< ::std::vec::Vec<::std::primitive::u8>, ::::errors::db_mixed_stack_arguments::GetDataByKey0Error, > + ::std::marker::Send + ::std::marker::Sync + 'mock, >>, } #[allow(clippy::redundant_closure)] impl<'mock> getDataByKey0<'mock> { pub(crate) fn unimplemented() -> Self { Self { closure: ::std::sync::Mutex::new(::std::boxed::Box::new(|_: ::std::string::String| panic!( "{}::{} is not mocked", "DbMixedStackArguments", "getDataByKey0", ))), } } pub fn ret(&self, value: ::std::vec::Vec<::std::primitive::u8>) { self.mock(move |_: ::std::string::String| value.clone()); } pub fn mock(&self, mut mock: impl ::std::ops::FnMut(::std::string::String) -> ::std::vec::Vec<::std::primitive::u8> + ::std::marker::Send + ::std::marker::Sync + 'mock) { let mut closure = self.closure.lock().unwrap(); *closure = ::std::boxed::Box::new(move |key| ::std::result::Result::Ok(mock(key))); } pub fn mock_result(&self, mut mock: impl ::std::ops::FnMut(::std::string::String) -> ::std::result::Result<::std::vec::Vec<::std::primitive::u8>, ::::errors::db_mixed_stack_arguments::GetDataByKey0Error> + ::std::marker::Send + ::std::marker::Sync + 'mock) { let mut closure = self.closure.lock().unwrap(); *closure = ::std::boxed::Box::new(move |key| mock(key)); } pub fn throw(&self, exception: E) where E: ::std::convert::Into<::::errors::db_mixed_stack_arguments::GetDataByKey0Error>, 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::string::String| ::std::result::Result::Err(exception.clone().into())); } } pub struct getDataByKey1<'mock> { pub(crate) closure: ::std::sync::Mutex<::std::boxed::Box< dyn ::std::ops::FnMut(::std::string::String) -> ::std::result::Result< ::std::vec::Vec<::std::primitive::u8>, ::::errors::db_mixed_stack_arguments::GetDataByKey1Error, > + ::std::marker::Send + ::std::marker::Sync + 'mock, >>, } #[allow(clippy::redundant_closure)] impl<'mock> getDataByKey1<'mock> { pub(crate) fn unimplemented() -> Self { Self { closure: ::std::sync::Mutex::new(::std::boxed::Box::new(|_: ::std::string::String| panic!( "{}::{} is not mocked", "DbMixedStackArguments", "getDataByKey1", ))), } } pub fn ret(&self, value: ::std::vec::Vec<::std::primitive::u8>) { self.mock(move |_: ::std::string::String| value.clone()); } pub fn mock(&self, mut mock: impl ::std::ops::FnMut(::std::string::String) -> ::std::vec::Vec<::std::primitive::u8> + ::std::marker::Send + ::std::marker::Sync + 'mock) { let mut closure = self.closure.lock().unwrap(); *closure = ::std::boxed::Box::new(move |key| ::std::result::Result::Ok(mock(key))); } pub fn mock_result(&self, mut mock: impl ::std::ops::FnMut(::std::string::String) -> ::std::result::Result<::std::vec::Vec<::std::primitive::u8>, ::::errors::db_mixed_stack_arguments::GetDataByKey1Error> + ::std::marker::Send + ::std::marker::Sync + 'mock) { let mut closure = self.closure.lock().unwrap(); *closure = ::std::boxed::Box::new(move |key| mock(key)); } pub fn throw(&self, exception: E) where E: ::std::convert::Into<::::errors::db_mixed_stack_arguments::GetDataByKey1Error>, 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::string::String| ::std::result::Result::Err(exception.clone().into())); } } } }