use minicbor::{CborLen, Decode, Encode};
use ockam::Message;
use ockam_core::{cbor_encode_preallocate, Decodable, Encodable, Encoded};
#[derive(Debug, Clone, Encode, Decode, CborLen, PartialEq, Eq, Message)]
#[rustfmt::skip]
#[cbor(map)]
pub struct CreateTcpConnection {
#[n(1)] pub addr: String,
}
impl Encodable for CreateTcpConnection {
fn encode(self) -> ockam_core::Result<Encoded> {
cbor_encode_preallocate(self)
}
}
impl Decodable for CreateTcpConnection {
fn decode(e: &[u8]) -> ockam_core::Result<Self> {
Ok(minicbor::decode(e)?)
}
}
impl CreateTcpConnection {
pub fn new(addr: String) -> Self {
Self { addr }
}
}
#[derive(Debug, Clone, Encode, Decode, CborLen, PartialEq, Eq, Message)]
#[rustfmt::skip]
#[cbor(map)]
pub struct CreateTcpListener {
#[n(1)] pub addr: String,
}
impl Encodable for CreateTcpListener {
fn encode(self) -> ockam_core::Result<Encoded> {
cbor_encode_preallocate(self)
}
}
impl Decodable for CreateTcpListener {
fn decode(e: &[u8]) -> ockam_core::Result<Self> {
Ok(minicbor::decode(e)?)
}
}
impl CreateTcpListener {
pub fn new(addr: String) -> Self {
Self { addr }
}
}
#[derive(Debug, Clone, Encode, Decode, CborLen, Message)]
#[rustfmt::skip]
#[cbor(map)]
pub struct DeleteTransport {
#[n(1)] pub address: String,
}
impl Encodable for DeleteTransport {
fn encode(self) -> ockam_core::Result<Encoded> {
cbor_encode_preallocate(self)
}
}
impl Decodable for DeleteTransport {
fn decode(e: &[u8]) -> ockam_core::Result<Self> {
Ok(minicbor::decode(e)?)
}
}
impl DeleteTransport {
pub fn new(address: String) -> Self {
Self { address }
}
}