use super::{IDataCipher, ZmqError};
use crate::message::Metadata;
use std::fmt;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum MechanismStatus {
Initializing, Handshaking, Authenticating, Ready, Error, }
pub trait Mechanism: Send + Sync + fmt::Debug + 'static {
fn name(&self) -> &'static str;
fn process_token(&mut self, token: &[u8]) -> Result<(), ZmqError>;
fn produce_token(&mut self) -> Result<Option<Vec<u8>>, ZmqError>;
fn status(&self) -> MechanismStatus;
fn is_complete(&self) -> bool {
self.status() == MechanismStatus::Ready
}
fn is_error(&self) -> bool {
self.status() == MechanismStatus::Error
}
fn peer_identity(&self) -> Option<Vec<u8>>;
fn metadata(&self) -> Option<Metadata>;
fn as_any(&self) -> &dyn std::any::Any;
fn set_error(&mut self, reason: String);
fn error_reason(&self) -> Option<&str>;
fn zap_request_needed(&mut self) -> Option<Vec<Vec<u8>>>;
fn process_zap_reply(&mut self, reply_frames: &[Vec<u8>]) -> Result<(), ZmqError>;
fn into_data_cipher_parts(self: Box<Self>) -> Result<(Box<dyn IDataCipher>, Option<Vec<u8>>), ZmqError>;
}