Validate config on load; document the SDK's core traits
Some checks failed
CI / check (push) Failing after 53s
Some checks failed
CI / check (push) Failing after 53s
Config::load now checks the SID is 3 alphanumeric chars and that server.name and uplink.host are set, failing with a clear message instead of a cryptic link-time error. Give the Service and Protocol traits and ServiceCtx proper rustdoc so cargo doc is useful to module authors.
This commit is contained in:
parent
955e55d47f
commit
0ed6684522
2 changed files with 29 additions and 6 deletions
|
|
@ -121,9 +121,9 @@ pub enum RegReply {
|
|||
NickServ { agent: String, uid: String, nick: String },
|
||||
}
|
||||
|
||||
// The ircd link layer. The engine only ever sees NetEvent / NetAction; raw
|
||||
// server-to-server lines live entirely behind a Protocol impl, so a new ircd is
|
||||
// one new module and the engine is untouched.
|
||||
/// The ircd link layer. The engine only ever sees [`NetEvent`] / [`NetAction`];
|
||||
/// raw server-to-server lines live entirely behind a `Protocol` impl, so a new
|
||||
/// ircd is one new module and the engine is untouched.
|
||||
pub trait Protocol: Send {
|
||||
/// Lines to send immediately on connect (auth / capability negotiation).
|
||||
fn handshake(&mut self) -> Vec<String>;
|
||||
|
|
@ -226,8 +226,9 @@ pub struct Sender<'a> {
|
|||
pub privs: Privs,
|
||||
}
|
||||
|
||||
// The intent sink a service writes to. A service never mutates the network or
|
||||
// the store itself; it pushes normalized actions the engine drains and applies.
|
||||
/// The intent sink a service writes to. A service never mutates the network or
|
||||
/// the store itself; it pushes normalized actions (via [`ServiceCtx::notice`]
|
||||
/// and friends) that the engine drains and applies.
|
||||
#[derive(Default)]
|
||||
pub struct ServiceCtx {
|
||||
pub actions: Vec<NetAction>,
|
||||
|
|
@ -1075,6 +1076,10 @@ pub struct IncidentView {
|
|||
|
||||
// A pseudo-client (NickServ, ChanServ, ...). Introduced at burst, receives the
|
||||
// commands users message it, reads/writes the store, and pushes actions.
|
||||
/// A pseudo-client such as NickServ or ChanServ. Implement this, register the
|
||||
/// crate in the daemon, and the engine routes a PRIVMSG addressed to the
|
||||
/// service into [`Service::on_command`]. A service touches the network and the
|
||||
/// store only through [`NetView`] and [`Store`].
|
||||
pub trait Service: Send {
|
||||
fn nick(&self) -> &str;
|
||||
fn uid(&self) -> &str;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue