use flare_core::error::Result;
use async_trait::async_trait;
use flare_core::flare_net::net::{Message as ProtoMessage, Platform};
use std::pin::Pin;
use std::future::Future;
use std::time::Duration;
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum ConnectionState {
Connected,
Disconnected,
Error,
}
#[async_trait]
pub trait Connection: Send + Sync {
fn id(&self) -> &str;
fn remote_addr(&self) -> &str;
fn platform(&self) -> Platform;
fn protocol(&self) -> &str;
async fn is_active(&self, timeout: Duration) -> bool;
fn send(&self, msg: ProtoMessage) -> Pin<Box<dyn Future<Output = Result<()>> + Send + '_>>;
fn receive(&self) -> Pin<Box<dyn Future<Output = Result<ProtoMessage>> + Send + '_>>;
fn close(&self) -> Pin<Box<dyn Future<Output = Result<()>> + Send + '_>>;
fn clone_box(&self) -> Box<dyn Connection>;
}