use super::*;
pub trait NullService: Service {}
pub fn create_null_service() -> Box<dyn NullService> {
Box::new(NullServiceImpl)
}
struct NullServiceImpl;
impl NullService for NullServiceImpl {}
impl Service for NullServiceImpl {}
pub struct NullServiceBoxDispatcher {}
impl NullServiceBoxDispatcher {
fn new(_object: Box<dyn NullService>) -> Self {
Self {}
}
}
impl crate::macro_env::Dispatch for NullServiceBoxDispatcher {
fn dispatch_and_call(&self, _method: crate::macro_env::MethodId, _args: &[u8]) -> Vec<u8> {
panic!("Invalid remote-trait-object call. Fatal Error.")
}
}
impl crate::macro_env::IntoSkeleton<dyn NullService> for Box<dyn NullService> {
fn into_skeleton(self) -> crate::macro_env::Skeleton {
crate::macro_env::create_skeleton(std::sync::Arc::new(NullServiceBoxDispatcher::new(self)))
}
}
pub struct NullServiceArcDispatcher {}
impl NullServiceArcDispatcher {
fn new(_object: std::sync::Arc<dyn NullService>) -> Self {
Self {}
}
}
impl crate::macro_env::Dispatch for NullServiceArcDispatcher {
fn dispatch_and_call(&self, _method: crate::macro_env::MethodId, _args: &[u8]) -> Vec<u8> {
panic!("Invalid remote-trait-object call. Fatal Error.")
}
}
impl crate::macro_env::IntoSkeleton<dyn NullService> for std::sync::Arc<dyn NullService> {
fn into_skeleton(self) -> crate::macro_env::Skeleton {
crate::macro_env::create_skeleton(std::sync::Arc::new(NullServiceArcDispatcher::new(self)))
}
}
pub struct NullServiceRwLockDispatcher {}
impl NullServiceRwLockDispatcher {
fn new(_object: std::sync::Arc<parking_lot::RwLock<dyn NullService>>) -> Self {
Self {}
}
}
impl crate::macro_env::Dispatch for NullServiceRwLockDispatcher {
fn dispatch_and_call(&self, _method: crate::macro_env::MethodId, _args: &[u8]) -> Vec<u8> {
panic!("Invalid remote-trait-object call. Fatal Error.")
}
}
impl crate::macro_env::IntoSkeleton<dyn NullService> for std::sync::Arc<parking_lot::RwLock<dyn NullService>> {
fn into_skeleton(self) -> crate::macro_env::Skeleton {
crate::macro_env::create_skeleton(std::sync::Arc::new(NullServiceRwLockDispatcher::new(self)))
}
}
#[derive(Debug)]
pub struct NullServiceProxy {
handle: crate::macro_env::Handle,
}
impl NullService for NullServiceProxy {}
impl crate::macro_env::Service for NullServiceProxy {}
impl crate::macro_env::ImportProxy<dyn NullService> for Box<dyn NullService> {
fn import_proxy(
port: std::sync::Weak<dyn crate::macro_env::Port>,
handle: crate::macro_env::HandleToExchange,
) -> Self {
Box::new(NullServiceProxy {
handle: crate::macro_env::Handle::new(handle, port),
})
}
}
impl crate::macro_env::ImportProxy<dyn NullService> for std::sync::Arc<dyn NullService> {
fn import_proxy(
port: std::sync::Weak<dyn crate::macro_env::Port>,
handle: crate::macro_env::HandleToExchange,
) -> Self {
std::sync::Arc::new(NullServiceProxy {
handle: crate::macro_env::Handle::new(handle, port),
})
}
}
impl crate::macro_env::ImportProxy<dyn NullService> for std::sync::Arc<parking_lot::RwLock<dyn NullService>> {
fn import_proxy(
port: std::sync::Weak<dyn crate::macro_env::Port>,
handle: crate::macro_env::HandleToExchange,
) -> Self {
std::sync::Arc::new(parking_lot::RwLock::new(NullServiceProxy {
handle: crate::macro_env::Handle::new(handle, port),
}))
}
}