pub mod decoder;
pub mod encoder;
use std::collections::HashMap;
use args::{FieldArgument, AmqpString};
pub use self::connection::ConnectionClass;
pub use self::channel::ChannelClass;
pub use self::exchange::ExchangeClass;
pub use self::queue::QueueClass;
pub use self::basic::BasicClass;
pub use self::tx::TxClass;
#[derive(PartialEq, Clone, Debug)]
pub enum MethodPayload {
Connection(ConnectionClass),
Channel(ChannelClass),
Exchange(ExchangeClass),
Queue(QueueClass),
Basic(BasicClass),
Tx(TxClass),
}
impl MethodPayload {
pub fn connection(&self) -> Option<&ConnectionClass> {
match self {
&MethodPayload::Connection(ref c) => Some(c),
_ => None,
}
}
pub fn channel(&self) -> Option<&ChannelClass> {
match self {
&MethodPayload::Channel(ref c) => Some(c),
_ => None,
}
}
pub fn exchange(&self) -> Option<&ExchangeClass> {
match self {
&MethodPayload::Exchange(ref c) => Some(c),
_ => None,
}
}
pub fn queue(&self) -> Option<&QueueClass> {
match self {
&MethodPayload::Queue(ref c) => Some(c),
_ => None,
}
}
pub fn basic(&self) -> Option<&BasicClass> {
match self {
&MethodPayload::Basic(ref c) => Some(c),
_ => None,
}
}
pub fn tx(&self) -> Option<&TxClass> {
match self {
&MethodPayload::Tx(ref c) => Some(c),
_ => None,
}
}
}
pub mod connection {
use super::*;
#[derive(PartialEq, Clone, Debug)]
pub enum ConnectionClass {
Start(StartMethod),
StartOk(StartOkMethod),
Secure(SecureMethod),
SecureOk(SecureOkMethod),
Tune(TuneMethod),
TuneOk(TuneOkMethod),
Open(OpenMethod),
OpenOk(OpenOkMethod),
Close(CloseMethod),
CloseOk,
Blocked(BlockedMethod),
Unblocked,
}
impl ConnectionClass {
pub fn start(&self) -> Option<&StartMethod> {
match self {
&ConnectionClass::Start(ref m) => Some(m),
_ => None,
}
}
pub fn start_ok(&self) -> Option<&StartOkMethod> {
match self {
&ConnectionClass::StartOk(ref m) => Some(m),
_ => None,
}
}
pub fn secure(&self) -> Option<&SecureMethod> {
match self {
&ConnectionClass::Secure(ref m) => Some(m),
_ => None,
}
}
pub fn secure_ok(&self) -> Option<&SecureOkMethod> {
match self {
&ConnectionClass::SecureOk(ref m) => Some(m),
_ => None,
}
}
pub fn tune(&self) -> Option<&TuneMethod> {
match self {
&ConnectionClass::Tune(ref m) => Some(m),
_ => None,
}
}
pub fn tune_ok(&self) -> Option<&TuneOkMethod> {
match self {
&ConnectionClass::TuneOk(ref m) => Some(m),
_ => None,
}
}
pub fn open(&self) -> Option<&OpenMethod> {
match self {
&ConnectionClass::Open(ref m) => Some(m),
_ => None,
}
}
pub fn open_ok(&self) -> Option<&OpenOkMethod> {
match self {
&ConnectionClass::OpenOk(ref m) => Some(m),
_ => None,
}
}
pub fn close(&self) -> Option<&CloseMethod> {
match self {
&ConnectionClass::Close(ref m) => Some(m),
_ => None,
}
}
pub fn close_ok(&self) -> Option<()> {
match self {
&ConnectionClass::CloseOk => Some(()),
_ => None,
}
}
pub fn blocked(&self) -> Option<&BlockedMethod> {
match self {
&ConnectionClass::Blocked(ref m) => Some(m),
_ => None,
}
}
pub fn unblocked(&self) -> Option<()> {
match self {
&ConnectionClass::Unblocked => Some(()),
_ => None,
}
}
}
#[derive(PartialEq, Clone, Debug)]
pub struct StartMethod {
pub version_major: u8,
pub version_minor: u8,
pub server_properties: HashMap<AmqpString, FieldArgument>,
pub mechanisms: AmqpString,
pub locales: AmqpString,
}
#[derive(PartialEq, Clone, Debug)]
pub struct StartOkMethod {
pub client_properties: HashMap<AmqpString, FieldArgument>,
pub mechanism: AmqpString,
pub response: AmqpString,
pub locale: AmqpString,
}
#[derive(PartialEq, Clone, Debug)]
pub struct SecureMethod {
pub challenge: AmqpString,
}
#[derive(PartialEq, Clone, Debug)]
pub struct SecureOkMethod {
pub response: AmqpString,
}
#[derive(PartialEq, Clone, Debug)]
pub struct TuneMethod {
pub channel_max: u16,
pub frame_max: u32,
pub heartbeat: u16,
}
#[derive(PartialEq, Clone, Debug)]
pub struct TuneOkMethod {
pub channel_max: u16,
pub frame_max: u32,
pub heartbeat: u16,
}
#[derive(PartialEq, Clone, Debug)]
pub struct OpenMethod {
pub virtual_host: AmqpString,
pub reserved1: AmqpString,
pub reserved2: bool,
}
#[derive(PartialEq, Clone, Debug)]
pub struct OpenOkMethod {
pub reserved1: AmqpString,
}
#[derive(PartialEq, Clone, Debug)]
pub struct CloseMethod {
pub reply_code: u16,
pub reply_text: AmqpString,
pub class_id: u16,
pub method_id: u16,
}
#[derive(PartialEq, Clone, Debug)]
pub struct BlockedMethod {
pub reason: AmqpString,
}
}
pub mod channel {
use super::*;
#[derive(PartialEq, Clone, Debug)]
pub enum ChannelClass {
Open(OpenMethod),
OpenOk(OpenOkMethod),
Flow(FlowMethod),
FlowOk(FlowOkMethod),
Close(CloseMethod),
CloseOk,
}
impl ChannelClass {
pub fn open(&self) -> Option<&OpenMethod> {
match self {
&ChannelClass::Open(ref m) => Some(m),
_ => None,
}
}
pub fn open_ok(&self) -> Option<&OpenOkMethod> {
match self {
&ChannelClass::OpenOk(ref m) => Some(m),
_ => None,
}
}
pub fn flow(&self) -> Option<&FlowMethod> {
match self {
&ChannelClass::Flow(ref m) => Some(m),
_ => None,
}
}
pub fn flow_ok(&self) -> Option<&FlowOkMethod> {
match self {
&ChannelClass::FlowOk(ref m) => Some(m),
_ => None,
}
}
pub fn close(&self) -> Option<&CloseMethod> {
match self {
&ChannelClass::Close(ref m) => Some(m),
_ => None,
}
}
pub fn close_ok(&self) -> Option<()> {
match self {
&ChannelClass::CloseOk => Some(()),
_ => None,
}
}
}
#[derive(PartialEq, Clone, Debug)]
pub struct OpenMethod {
pub reserved1: AmqpString,
}
#[derive(PartialEq, Clone, Debug)]
pub struct OpenOkMethod {
pub reserved1: AmqpString,
}
#[derive(PartialEq, Clone, Debug)]
pub struct FlowMethod {
pub active: bool,
}
#[derive(PartialEq, Clone, Debug)]
pub struct FlowOkMethod {
pub active: bool,
}
#[derive(PartialEq, Clone, Debug)]
pub struct CloseMethod {
pub reply_code: u16,
pub reply_text: AmqpString,
pub class_id: u16,
pub method_id: u16,
}
}
pub mod exchange {
use super::*;
#[derive(PartialEq, Clone, Debug)]
pub enum ExchangeClass {
Declare(DeclareMethod),
DeclareOk,
Delete(DeleteMethod),
DeleteOk,
Bind(BindMethod),
BindOk, Unbind(UnbindMethod),
UnbindOk, }
impl ExchangeClass {
pub fn declare(&self) -> Option<&DeclareMethod> {
match self {
&ExchangeClass::Declare(ref m) => Some(m),
_ => None,
}
}
pub fn declare_ok(&self) -> Option<()> {
match self {
&ExchangeClass::DeclareOk => Some(()),
_ => None,
}
}
pub fn delete(&self) -> Option<&DeleteMethod> {
match self {
&ExchangeClass::Delete(ref m) => Some(m),
_ => None,
}
}
pub fn delete_ok(&self) -> Option<()> {
match self {
&ExchangeClass::DeleteOk => Some(()),
_ => None,
}
}
pub fn bind(&self) -> Option<&BindMethod> {
match self {
&ExchangeClass::Bind(ref m) => Some(m),
_ => None,
}
}
pub fn bind_ok(&self) -> Option<()> {
match self {
&ExchangeClass::BindOk => Some(()),
_ => None,
}
}
pub fn unbind(&self) -> Option<&UnbindMethod> {
match self {
&ExchangeClass::Unbind(ref m) => Some(m),
_ => None,
}
}
pub fn unbind_ok(&self) -> Option<()> {
match self {
&ExchangeClass::UnbindOk => Some(()),
_ => None,
}
}
}
#[derive(PartialEq, Clone, Debug)]
pub struct DeclareMethod {
pub reserved1: u16,
pub exchange: AmqpString,
pub typ: AmqpString,
pub passive: bool,
pub durable: bool,
pub auto_delete: bool, pub internal: bool, pub no_wait: bool,
pub arguments: HashMap<AmqpString, FieldArgument>,
}
#[derive(PartialEq, Clone, Debug)]
pub struct DeleteMethod {
pub reserved1: u16,
pub exchange: AmqpString,
pub if_unused: bool,
pub no_wait: bool,
}
#[derive(PartialEq, Clone, Debug)]
pub struct BindMethod {
pub reserved1: u16,
pub destination: AmqpString,
pub source: AmqpString,
pub routing_key: AmqpString,
pub no_wait: bool,
pub arguments: HashMap<AmqpString, FieldArgument>,
}
#[derive(PartialEq, Clone, Debug)]
pub struct UnbindMethod {
pub reserved1: u16,
pub destination: AmqpString,
pub source: AmqpString,
pub routing_key: AmqpString,
pub no_wait: bool,
pub arguments: HashMap<AmqpString, FieldArgument>,
}
}
pub mod queue {
use super::*;
#[derive(PartialEq, Clone, Debug)]
pub enum QueueClass {
Declare(DeclareMethod),
DeclareOk(DeclareOkMethod),
Bind(BindMethod),
BindOk,
Unbind(UnbindMethod),
UnbindOk,
Purge(PurgeMethod),
PurgeOk(PurgeOkMethod),
Delete(DeleteMethod),
DeleteOk(DeleteOkMethod),
}
impl QueueClass {
pub fn declare(&self) -> Option<&DeclareMethod> {
match self {
&QueueClass::Declare(ref m) => Some(m),
_ => None,
}
}
pub fn declare_ok(&self) -> Option<&DeclareOkMethod> {
match self {
&QueueClass::DeclareOk(ref m) => Some(m),
_ => None,
}
}
pub fn bind(&self) -> Option<&BindMethod> {
match self {
&QueueClass::Bind(ref m) => Some(m),
_ => None,
}
}
pub fn bind_ok(&self) -> Option<()> {
match self {
&QueueClass::BindOk => Some(()),
_ => None,
}
}
pub fn unbind(&self) -> Option<&UnbindMethod> {
match self {
&QueueClass::Unbind(ref m) => Some(m),
_ => None,
}
}
pub fn unbind_ok(&self) -> Option<()> {
match self {
&QueueClass::UnbindOk => Some(()),
_ => None,
}
}
pub fn purge(&self) -> Option<&PurgeMethod> {
match self {
&QueueClass::Purge(ref m) => Some(m),
_ => None,
}
}
pub fn purge_ok(&self) -> Option<&PurgeOkMethod> {
match self {
&QueueClass::PurgeOk(ref m) => Some(m),
_ => None,
}
}
pub fn delete(&self) -> Option<&DeleteMethod> {
match self {
&QueueClass::Delete(ref m) => Some(m),
_ => None,
}
}
pub fn delete_ok(&self) -> Option<&DeleteOkMethod> {
match self {
&QueueClass::DeleteOk(ref m) => Some(m),
_ => None,
}
}
}
#[derive(PartialEq, Clone, Debug)]
pub struct DeclareMethod {
pub reserved1: u16,
pub queue: AmqpString,
pub passive: bool,
pub durable: bool,
pub exclusive: bool,
pub auto_delete: bool,
pub no_wait: bool,
pub arguments: HashMap<AmqpString, FieldArgument>,
}
#[derive(PartialEq, Clone, Debug)]
pub struct DeclareOkMethod {
pub queue: AmqpString,
pub message_count: u32,
pub consumer_count: u32,
}
#[derive(PartialEq, Clone, Debug)]
pub struct BindMethod {
pub reserved1: u16,
pub queue: AmqpString,
pub exchange: AmqpString,
pub routing_key: AmqpString,
pub no_wait: bool,
pub arguments: HashMap<AmqpString, FieldArgument>,
}
#[derive(PartialEq, Clone, Debug)]
pub struct UnbindMethod {
pub reserved1: u16,
pub queue: AmqpString,
pub exchange: AmqpString,
pub routing_key: AmqpString,
pub arguments: HashMap<AmqpString, FieldArgument>,
}
#[derive(PartialEq, Clone, Debug)]
pub struct PurgeMethod {
pub reserved1: u16,
pub queue: AmqpString,
pub no_wait: bool,
}
#[derive(PartialEq, Clone, Debug)]
pub struct PurgeOkMethod {
pub message_count: u32,
}
#[derive(PartialEq, Clone, Debug)]
pub struct DeleteMethod {
pub reserved1: u16,
pub queue: AmqpString,
pub if_unused: bool,
pub if_empty: bool,
pub no_wait: bool,
}
#[derive(PartialEq, Clone, Debug)]
pub struct DeleteOkMethod {
pub message_count: u32,
}
}
pub mod basic {
use super::*;
#[derive(PartialEq, Clone, Debug)]
pub enum BasicClass {
Qos(QosMethod),
QosOk,
Consume(ConsumeMethod),
ConsumeOk(ConsumeOkMethod),
Cancel(CancelMethod),
CancelOk(CancelOkMethod),
Publish(PublishMethod),
Return(ReturnMethod),
Deliver(DeliverMethod),
Get(GetMethod),
GetOk(GetOkMethod),
GetEmpty(GetEmptyMethod),
Ack(AckMethod),
Reject(RejectMethod),
Nack(NackMethod), RecoverAsync(RecoverAsyncMethod),
Recover(RecoverMethod),
RecoverOk,
}
impl BasicClass {
pub fn qos(&self) -> Option<&QosMethod> {
match self {
&BasicClass::Qos(ref m) => Some(m),
_ => None,
}
}
pub fn qos_ok(&self) -> Option<()> {
match self {
&BasicClass::QosOk => Some(()),
_ => None,
}
}
pub fn consume(&self) -> Option<&ConsumeMethod> {
match self {
&BasicClass::Consume(ref m) => Some(m),
_ => None,
}
}
pub fn consume_ok(&self) -> Option<&ConsumeOkMethod> {
match self {
&BasicClass::ConsumeOk(ref m) => Some(m),
_ => None,
}
}
pub fn cancel(&self) -> Option<&CancelMethod> {
match self {
&BasicClass::Cancel(ref m) => Some(m),
_ => None,
}
}
pub fn cancel_ok(&self) -> Option<&CancelOkMethod> {
match self {
&BasicClass::CancelOk(ref m) => Some(m),
_ => None,
}
}
pub fn publish(&self) -> Option<&PublishMethod> {
match self {
&BasicClass::Publish(ref m) => Some(m),
_ => None,
}
}
pub fn return_(&self) -> Option<&ReturnMethod> {
match self {
&BasicClass::Return(ref m) => Some(m),
_ => None,
}
}
pub fn deliver(&self) -> Option<&DeliverMethod> {
match self {
&BasicClass::Deliver(ref m) => Some(m),
_ => None,
}
}
pub fn get(&self) -> Option<&GetMethod> {
match self {
&BasicClass::Get(ref m) => Some(m),
_ => None,
}
}
pub fn get_ok(&self) -> Option<&GetOkMethod> {
match self {
&BasicClass::GetOk(ref m) => Some(m),
_ => None,
}
}
pub fn get_empty(&self) -> Option<&GetEmptyMethod> {
match self {
&BasicClass::GetEmpty(ref m) => Some(m),
_ => None,
}
}
pub fn ack(&self) -> Option<&AckMethod> {
match self {
&BasicClass::Ack(ref m) => Some(m),
_ => None,
}
}
pub fn reject(&self) -> Option<&RejectMethod> {
match self {
&BasicClass::Reject(ref m) => Some(m),
_ => None,
}
}
pub fn nack(&self) -> Option<&NackMethod> {
match self {
&BasicClass::Nack(ref m) => Some(m),
_ => None,
}
}
pub fn recover_async(&self) -> Option<&RecoverAsyncMethod> {
match self {
&BasicClass::RecoverAsync(ref m) => Some(m),
_ => None,
}
}
pub fn recover(&self) -> Option<&RecoverMethod> {
match self {
&BasicClass::Recover(ref m) => Some(m),
_ => None,
}
}
pub fn recover_ok(&self) -> Option<()> {
match self {
&BasicClass::RecoverOk => Some(()),
_ => None,
}
}
}
#[derive(PartialEq, Clone, Debug)]
pub struct QosMethod {
pub prefetch_size: u32,
pub prefetch_count: u16,
pub global: bool,
}
#[derive(PartialEq, Clone, Debug)]
pub struct ConsumeMethod {
pub reserved1: u16,
pub queue: AmqpString,
pub consumer_tag: AmqpString,
pub no_local: bool,
pub no_ack: bool,
pub exclusive: bool,
pub no_wait: bool,
pub arguments: HashMap<AmqpString, FieldArgument>,
}
#[derive(PartialEq, Clone, Debug)]
pub struct ConsumeOkMethod {
pub consumer_tag: AmqpString,
}
#[derive(PartialEq, Clone, Debug)]
pub struct CancelMethod {
pub consumer_tag: AmqpString,
pub no_wait: bool,
}
#[derive(PartialEq, Clone, Debug)]
pub struct CancelOkMethod {
pub consumer_tag: AmqpString,
}
#[derive(PartialEq, Clone, Debug)]
pub struct PublishMethod {
pub reserved1: u16,
pub exchange: AmqpString,
pub routing_key: AmqpString,
pub mandatory: bool,
pub immediate: bool,
}
#[derive(PartialEq, Clone, Debug)]
pub struct ReturnMethod {
pub reply_code: u16,
pub reply_text: AmqpString,
pub exchange: AmqpString,
pub routing_key: AmqpString,
}
#[derive(PartialEq, Clone, Debug)]
pub struct DeliverMethod {
pub consumer_tag: AmqpString,
pub delivery_tag: u64,
pub redeliverd: bool,
pub exchange: AmqpString,
pub routing_key: AmqpString,
}
#[derive(PartialEq, Clone, Debug)]
pub struct GetMethod {
pub reserved1: u16,
pub queue: AmqpString,
pub no_ack: bool,
}
#[derive(PartialEq, Clone, Debug)]
pub struct GetOkMethod {
pub delivery_tag: u64,
pub redeliverd: bool,
pub exchange: AmqpString,
pub routing_key: AmqpString,
pub message_count: u32,
}
#[derive(PartialEq, Clone, Debug)]
pub struct GetEmptyMethod {
pub reserved1: AmqpString,
}
#[derive(PartialEq, Clone, Debug)]
pub struct AckMethod {
pub delivery_tag: u64,
pub multiple: bool,
}
#[derive(PartialEq, Clone, Debug)]
pub struct RejectMethod {
pub delivery_tag: u64,
pub requeue: bool,
}
#[derive(PartialEq, Clone, Debug)]
pub struct RecoverAsyncMethod {
pub requeue: bool,
}
#[derive(PartialEq, Clone, Debug)]
pub struct RecoverMethod {
pub requeue: bool,
}
#[derive(PartialEq, Clone, Debug)]
pub struct NackMethod {
pub delivery_tag: u64,
pub multiple: bool,
}
}
pub mod tx {
#[derive(PartialEq, Clone, Debug)]
pub enum TxClass {
Select,
SelectOk,
Commit,
CommitOk,
Rollback,
RollbackOk,
}
impl TxClass {
pub fn select(&self) -> Option<()> {
match self {
&TxClass::Select => Some(()),
_ => None,
}
}
pub fn select_ok(&self) -> Option<()> {
match self {
&TxClass::SelectOk => Some(()),
_ => None,
}
}
pub fn commit(&self) -> Option<()> {
match self {
&TxClass::Commit => Some(()),
_ => None,
}
}
pub fn commit_ok(&self) -> Option<()> {
match self {
&TxClass::CommitOk => Some(()),
_ => None,
}
}
pub fn rollback(&self) -> Option<()> {
match self {
&TxClass::Rollback => Some(()),
_ => None,
}
}
pub fn rollback_ok(&self) -> Option<()> {
match self {
&TxClass::RollbackOk => Some(()),
_ => None,
}
}
}
}