pub struct Session<T: Transport> { /* private fields */ }ssh or tls only.Expand description
A NETCONF client session over a secure transport T.
Session instances provide direct access to asynchronous NETCONF protocol operations. The
library user is responsible for ensuring the correct ordering of operations to ensure, for
example, safe config modification. See RFC6241 for additional guidance.
Implementations§
Source§impl Session<Tls>
impl Session<Tls>
Sourcepub async fn tls<A, S>(
addr: A,
server_name: S,
ca_cert: CertificateDer<'_>,
client_cert: CertificateDer<'static>,
client_key: PrivateKeyDer<'static>,
) -> Result<Self, Error>where
A: ToSocketAddrs + Debug + Send,
S: TryInto<ServerName<'static>> + Debug + Send,
Error: From<S::Error>,
Available on crate feature tls only.
pub async fn tls<A, S>(
addr: A,
server_name: S,
ca_cert: CertificateDer<'_>,
client_cert: CertificateDer<'static>,
client_key: PrivateKeyDer<'static>,
) -> Result<Self, Error>where
A: ToSocketAddrs + Debug + Send,
S: TryInto<ServerName<'static>> + Debug + Send,
Error: From<S::Error>,
tls only.Establish a new NETCONF session over a TLS transport.
Source§impl<T: Transport> Session<T>
impl<T: Transport> Session<T>
Sourcepub async fn rpc<O, F>(
&mut self,
build_fn: F,
) -> Result<impl Future<Output = Result<<O::Reply as IntoResult>::Ok, Error>>, Error>
pub async fn rpc<O, F>( &mut self, build_fn: F, ) -> Result<impl Future<Output = Result<<O::Reply as IntoResult>::Ok, Error>>, Error>
Execute a NETCONF RPC operation on the current session.
See the rpc::operation module for available operations and their request builder APIs.
RPC requests are built and validated against the Context of the current session - in
particular, against the list of capabilities advertised by the NETCONF server in the
<hello> message exchange.
The build_fn closure must accept an instance of the operation request
Builder, configure the builder, and then convert it to a
validated request by calling Builder::finish().
This method returns a nested Future, reflecting the fact that the request is sent to
the NETCONF server asynchronously and then the response is later received asynchronously.
The Output of both the outer and inner Future are of type Result.
An Err variant returned by awaiting the outer future indicates either a request validation
error or a session/transport error encountered while sending the RPC request.
An Err variant returned by awaiting the inner future indicates either a
session/transport error while receiving the <rpc-reply> message, an error parsing the
received XML, or one-or-more application layer errors returned by the NETCONF server. The
latter case may be identified by matching on the Error::RpcError variant.