#![warn(missing_docs)]
#![doc = include_str!("../README.md")]
use std::{fmt::Display, ops::Deref};
#[allow(clippy::let_unit_value)]
#[allow(missing_docs)]
pub(crate) mod generated {
pub(crate) mod stubs;
}
#[allow(missing_docs)]
pub mod messages {
include!("generated/messages/includes.rs");
pub use adventure_control::*;
pub use dfproto::*;
pub use dfstockpiles::*;
pub use dwarf_control::*;
pub use itemdef_instrument::*;
pub use proto::enums::ui_sidebar_mode::*;
pub use remote_fortress_reader::*;
}
pub mod stubs {
pub use crate::generated::stubs::*;
}
pub trait Message: prost::Message + prost::Name + Default {}
impl<T: prost::Message + prost::Name + Default> Message for T {}
pub trait Channel {
type TError;
fn request<TRequest: Message, TReply: Message>(
&mut self,
plugin: &'static str,
name: &'static str,
request: TRequest,
) -> Result<Reply<TReply>, Self::TError>;
}
pub struct Reply<T> {
pub reply: T,
pub fragments: Vec<messages::CoreTextFragment>,
}
impl<T> Deref for Reply<T> {
type Target = T;
fn deref(&self) -> &Self::Target {
&self.reply
}
}
impl<T: Display> Display for Reply<T> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.reply)
}
}
pub mod reflection {
pub struct RemoteProcedureDescriptor {
pub name: &'static str,
pub plugin_name: &'static str,
pub input_type: String,
pub output_type: String,
}
pub trait StubReflection {
fn list_methods() -> Vec<RemoteProcedureDescriptor>;
}
}