1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
#![warn(missing_docs)]
#![doc = include_str!("../README.md")]
/// Raw protobuf messages
pub mod messages {
pub use crate::generated::messages::*;
}
/// Stubs exposing the feature of the DFHack remote API.
///
/// Each stub is generated from a DFHack plugin.
/// This module is auto-generated from DFHack sources.
pub mod stubs {
pub use crate::generated::stubs::*;
}
/// The `Channel` is the low-level exchange implementation.
///
/// It is in charge to serialize/deserialize messages, and exchange
/// them with Dwarf Fortress. It is not meant to be used as is, but to be passed to
/// It is analoguous to the gRPC channel.
pub trait Channel {
/// Type of the errors raised by the stub.
///
/// Defined by the channel implementation.
type TError;
/// Send a request to DFHack, and return its reply.
///
/// # Errors
///
/// The error type is defined by the channel implementation
///
/// # Arguments
///
/// * `plugin` - Name of the plugin implementing the request. Example: "RemoteFortressReader". Empty for core messages.
/// * `name` - Name of the method. Example: "GetDFVersion"
/// * `request` - Input of the method.
///
/// # Returns
///
/// A protobuf result type.
///
fn request<TRequest: protobuf::Message, TReply: protobuf::Message>(
&mut self,
plugin: String,
name: String,
request: TRequest,
) -> Result<TReply, Self::TError>;
}
#[cfg(feature = "reflection")]
/// Reflection for runtime inspection of the stubs.
pub mod reflection {
/// Descriptor of a remote procedure call
///
/// These are all the needed information to make a call
pub struct RemoteProcedureDescriptor {
/// Name of the RPC
pub name: String,
/// Plugin implementing the RPC
///
/// An empty string means the core API
pub plugin_name: String,
/// Input type
///
/// This is the full name of the protobuf message
pub input_type: String,
/// Output type
///
/// This is the full name of the protobuf message
pub output_type: String,
}
/// Ability for a stub to list its supported methods
///
/// This is mostly useful for testing purpose.
pub trait StubReflection {
/// List the supported remote calls
fn list_methods() -> Vec<RemoteProcedureDescriptor>;
}
}
/// Generated code from this crate
mod generated {
pub mod messages;
pub mod stubs;
}