[][src]Struct rpki_rtr::client::Client

pub struct Client<Sock, Target> { /* fields omitted */ }

An RTR client.

The client wraps a socket – represented by the type argument Sock which needs to support Tokio’s asynchronous writing and reading – and runs an RTR client over it. All data received will be passed on a VrpTarget of type Target.

The client keeps the socket open until either the server closes the connection, an error happens, or the client is dropped. It will periodically push a new dataset to the target.

Implementations

impl<Sock, Target> Client<Sock, Target>[src]

pub fn new(sock: Sock, target: Target, state: Option<State>) -> Self[src]

Creates a new client.

The client will use sock for communicating with the server and target to send updates to.

If the last state of a connection with this server is known – it can be determined by calling state on the client – it can be reused via the state argument. Make sure to also have the matching data in your target in this case since the there will not necessarily be a reset update. If you don’t have any state or don’t want to reuse an earlier session, simply pass None.

pub fn target(&self) -> &Target[src]

Returns a reference to the target.

pub fn target_mut(&mut self) -> &mut Target[src]

Returns a mutable reference to the target.

pub fn into_target(self) -> Target[src]

Converts the client into its target.

pub fn state(&self) -> Option<State>[src]

Returns the current state of the session.

The method will return None if there hasn’t been initial state and there has not been any converstation with the server yet.

impl<Sock, Target> Client<Sock, Target> where
    Sock: AsyncRead + AsyncWrite + Unpin,
    Target: VrpTarget
[src]

pub async fn run<'_>(&'_ mut self) -> Result<(), Error>[src]

Runs the client.

The method will keep the client asynchronously running, fetching any new data that becomes available on the server and pushing it to the target until either the server closes the connection – in which case the method will return Ok(()) –, an error happens – which will be returned or the future gets dropped.

pub async fn update<'_>(&'_ mut self) -> Result<Target::Update, Error>[src]

Performs a single update of the client data.

The method will wait until the next update is due and the request one single update from the server. It will request a new update object from the target, apply the update to that object and, if the update succeeds, return the object.

pub async fn reset<'_>(&'_ mut self) -> Result<Target::Update, Error>[src]

Performs a reset query.

Auto Trait Implementations

impl<Sock, Target> RefUnwindSafe for Client<Sock, Target> where
    Sock: RefUnwindSafe,
    Target: RefUnwindSafe

impl<Sock, Target> Send for Client<Sock, Target> where
    Sock: Send,
    Target: Send

impl<Sock, Target> Sync for Client<Sock, Target> where
    Sock: Sync,
    Target: Sync

impl<Sock, Target> Unpin for Client<Sock, Target> where
    Sock: Unpin,
    Target: Unpin

impl<Sock, Target> UnwindSafe for Client<Sock, Target> where
    Sock: UnwindSafe,
    Target: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.