Struct Session

Source
pub struct Session<T: Transport> { /* private fields */ }
Available on crate features 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<Ssh>

Source

pub async fn ssh<A>( addr: A, username: String, password: Password, ) -> Result<Self, Error>
where A: ToSocketAddrs + Send + Debug,

Available on crate feature ssh only.

Establish a new NETCONF session over an SSH transport.

Source§

impl Session<Tls>

Source

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>,

Available on crate feature tls only.

Establish a new NETCONF session over a TLS transport.

Source§

impl<T: Transport> Session<T>

Source

pub const fn context(&self) -> &Context

Get the session state Context of this session.

Source

pub async fn rpc<O, F>( &mut self, build_fn: F, ) -> Result<impl Future<Output = Result<<O::Reply as IntoResult>::Ok, Error>>, Error>
where O: Operation, F: FnOnce(O::Builder<'_>) -> Result<O, Error> + Send,

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.

Source

pub async fn close( self, ) -> Result<impl Future<Output = Result<(), Error>>, Error>

Close the NETCONF session gracefully using the <close-session> RPC operation.

Trait Implementations§

Source§

impl<T: Debug + Transport> Debug for Session<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Session<T>

§

impl<T> !RefUnwindSafe for Session<T>

§

impl<T> Send for Session<T>

§

impl<T> Sync for Session<T>

§

impl<T> Unpin for Session<T>

§

impl<T> !UnwindSafe for Session<T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more