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
//! Service trait for ma endpoint protocol handlers.
//!
//! A `Service` is analogous to an entry in `/etc/services`: a named protocol
//! on a ma endpoint. Register services on an `MaEndpoint` to handle incoming
//! connections on their protocol.
/// Trait that all ma services must implement.
///
/// Each service declares its protocol identifier and provides a handler for
/// incoming connections. Built-in services ship with ma-core; applications
/// add custom services via this trait.
///
/// # Examples
///
/// ```
/// use ma_core::Service;
///
/// struct MyService;
///
/// impl Service for MyService {
/// fn protocol(&self) -> &[u8] { b"/ma/my-service/0.0.1" }
/// }
/// ```
// ─── Well-known protocol constants (ma-core scope) ──────────────────────────
pub const INBOX_PROTOCOL_ID: &str = "/ma/inbox/0.0.1";
pub const INBOX_PROTOCOL: & = INBOX_PROTOCOL_ID.as_bytes;
pub const BROADCAST_PROTOCOL: & = b"/ma/broadcast/0.0.1";
pub const IPFS_PROTOCOL: & = b"/ma/ipfs/0.0.1";
/// The well-known broadcast topic string (same path as [`BROADCAST_PROTOCOL`]).
pub const BROADCAST_TOPIC: &str = "/ma/broadcast/0.0.1";
// ─── Content types ──────────────────────────────────────────────────────────
pub const CONTENT_TYPE_BROADCAST: &str = "application/x-ma-broadcast";
pub const CONTENT_TYPE_MESSAGE: &str = "application/x-ma-message";
pub const CONTENT_TYPE_IPFS_REQUEST: &str = "application/x-ma-ipfs-request";
pub const CONTENT_TYPE_DOC: &str = "application/x-ma-doc";