cdrs_async/
transport.rs

1use {
2  async_trait::async_trait,
3  std::{io, marker::Unpin, net},
4};
5
6use async_std::io::{Read, Write};
7
8/// Generic transport trait which is implemented by transports provided by CDRS.
9///
10/// It requires that implementor had following traits implementations: `Sized`,
11/// `Send`, `Unpin`, async `Read` and `Write`.
12#[async_trait]
13pub trait CDRSTransport: Sized + Read + Write + Send + Sync + Unpin {
14  // TODO: uncomment it
15  // /// Creates a new independently owned handle to the underlying socket.
16  // ///
17  // /// The returned TcpStream is a reference to the same stream that this object references.
18  // /// Both handles will read and write the same stream of data, and options set on one stream
19  // /// will be propagated to the other stream.
20  // async fn try_clone(&self) -> io::Result<Self>;
21
22  /// Shuts down the read, write, or both halves of this connection.
23  fn close(&mut self, close: net::Shutdown) -> io::Result<()>;
24
25  /// Method that checks that transport is alive
26  fn is_alive(&self) -> bool;
27}