Skip to main content

LinksClient

Struct LinksClient 

Source
pub struct LinksClient { /* private fields */ }
Expand description

Sends substitution queries to a LiNo server over any LinoProtocol.

A server pushes the changes a connection subscribed to between its replies; a pushed document starts with (notify: N). request sets the pushes it meets aside for receive_notification, so replies and pushes never get mixed up.

Implementations§

Source§

impl LinksClient

Source

pub fn connect( address: impl ToSocketAddrs, protocol: impl LinoProtocol + 'static, ) -> ProtocolResult<Self>

Connects to the TCP address using protocol for every message.

Source

pub fn connect_endpoint( endpoint: &str, protocol: impl LinoProtocol + 'static, ) -> ProtocolResult<Self>

Connects to an IPC endpoint such as 127.0.0.1:8080, unix:/tmp/links.sock, pipe:links or shm:/tmp/links.

Source

pub fn from_stream( stream: IpcStream, protocol: impl LinoProtocol + 'static, ) -> Self

Talks over an already connected stream of any transport.

Source

pub fn kind(&self) -> &'static str

The endpoint kind of the connection, such as tcp or shm.

Source

pub fn request( &mut self, document: &LinoDocument, ) -> ProtocolResult<LinoDocument>

Sends a parsed document and returns the reply document.

An (error: 'message') reply becomes ProtocolError::Remote.

Source

pub fn pending_notifications(&self) -> usize

The number of pushes received and not yet taken by receive_notification.

Source

pub fn receive_notification( &mut self, timeout: Duration, ) -> ProtocolResult<Option<LinoDocument>>

The next document the server pushed, (notify: N) and its changes, waiting up to timeout for one; Ok(None) when none arrived in time.

Fails when the connection closed, or when the server sent something other than a push while no request was waiting.

Source

pub fn query(&mut self, query: &str) -> ProtocolResult<LinoDocument>

Runs a LiNo substitution query; the empty query reads every link.

Source

pub fn query_lossless(&mut self, query: &str) -> ProtocolResult<LinoDocument>

Sends original query text without losing quoted-reference kinds. The peer must support super::query_document; legacy query behavior remains available through Self::query. No mutation is retried using a different wire representation after an error or unknown reply.

Source

pub fn query_text(&mut self, query: &str) -> ProtocolResult<String>

Like query, returning the reply as canonical text.

Source

pub fn authenticate(&mut self, token: &str) -> ProtocolResult<u32>

Sends (auth: token): every later request of the connection runs as the subject the server gives the token, which this returns (issue #149). A token the server does not know is a ProtocolError::Remote.

Trait Implementations§

Source§

impl Debug for LinksClient

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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

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

fn try_from(value: U) -> Result<T, !>

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.