mockforge_foundation/protocol.rs
1//! Protocol type enumeration for multi-protocol support
2//!
3//! The canonical `Protocol` enum. `mockforge-core::protocol_abstraction` and
4//! `mockforge-contracts::protocol` both re-export from here so cross-crate
5//! types can interoperate.
6
7use serde::{Deserialize, Serialize};
8use std::fmt;
9
10/// Protocol type enumeration for multi-protocol support
11#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
12#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
13pub enum Protocol {
14 /// HTTP/REST protocol for RESTful APIs
15 Http,
16 /// GraphQL protocol for GraphQL APIs
17 GraphQL,
18 /// gRPC protocol for gRPC services
19 Grpc,
20 /// WebSocket protocol for real-time bidirectional communication
21 WebSocket,
22 /// SMTP/Email protocol for email communication
23 Smtp,
24 /// MQTT protocol for IoT messaging and pub/sub
25 Mqtt,
26 /// FTP protocol for file transfer operations
27 Ftp,
28 /// Kafka protocol for distributed event streaming
29 Kafka,
30 /// RabbitMQ/AMQP protocol for message queuing
31 RabbitMq,
32 /// AMQP protocol for advanced message queuing scenarios
33 Amqp,
34 /// TCP protocol for raw TCP connections
35 Tcp,
36}
37
38impl fmt::Display for Protocol {
39 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
40 match self {
41 Protocol::Http => write!(f, "HTTP"),
42 Protocol::GraphQL => write!(f, "GraphQL"),
43 Protocol::Grpc => write!(f, "gRPC"),
44 Protocol::WebSocket => write!(f, "WebSocket"),
45 Protocol::Smtp => write!(f, "SMTP"),
46 Protocol::Mqtt => write!(f, "MQTT"),
47 Protocol::Ftp => write!(f, "FTP"),
48 Protocol::Kafka => write!(f, "Kafka"),
49 Protocol::RabbitMq => write!(f, "RabbitMQ"),
50 Protocol::Amqp => write!(f, "AMQP"),
51 Protocol::Tcp => write!(f, "TCP"),
52 }
53 }
54}