netconf_async/framer.rs
1//! NETCONF 1.0 end-of-message and 1.1 chunked framing ([RFC6242](https://www.rfc-editor.org/rfc/rfc6242.html)).
2
3use crate::error::NetconfClientResult;
4use async_trait::async_trait;
5
6/// Tokio-backed [`Framer`] implementation.
7#[cfg(feature = "tokio")]
8#[cfg_attr(docsrs, doc(cfg(feature = "tokio")))]
9pub mod async_framer;
10
11/// 1.0 message terminator (`]]>]]>`).
12pub const NETCONF_1_0_TERMINATOR: &str = "]]>]]>";
13
14/// Encode and decode NETCONF messages on a byte stream.
15#[async_trait]
16pub trait Framer: Send {
17 /// Switch from 1.0 (`]]>]]>`) to 1.1 chunked framing.
18 async fn upgrade(&mut self);
19 /// Read one framed message.
20 async fn read_async(&mut self) -> NetconfClientResult<String>;
21 /// Write one framed message.
22 async fn write_async(&mut self, rpc: &str) -> NetconfClientResult<()>;
23}