Skip to main content

netconf_async/
transport.rs

1//! Byte transport under the framer (SSH today).
2
3use crate::error::NetconfClientResult;
4use async_trait::async_trait;
5
6#[cfg(feature = "ssh")]
7#[cfg_attr(docsrs, doc(cfg(feature = "ssh")))]
8pub mod ssh;
9
10/// Byte pipe that carries framed NETCONF messages.
11///
12/// Implement this for a custom channel and pass it to
13/// [`Connection::new`](crate::connection::Connection::new).
14#[async_trait]
15pub trait Transport: Send {
16    /// Read one framed message.
17    async fn receive(&mut self) -> NetconfClientResult<String>;
18    /// Write one framed message.
19    async fn write(&mut self, rpc: &str) -> NetconfClientResult<()>;
20    /// Write one message and read the reply.
21    async fn write_and_receive(&mut self, rpc: &str) -> NetconfClientResult<String>;
22    /// Tear down the underlying channel.
23    async fn close(&mut self) -> NetconfClientResult<()>;
24    /// Switch from 1.0 end-of-message framing to 1.1 chunks ([RFC6242](https://www.rfc-editor.org/rfc/rfc6242.html)).
25    async fn upgrade(&mut self);
26}