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
impl LinksClient
Sourcepub fn connect(
address: impl ToSocketAddrs,
protocol: impl LinoProtocol + 'static,
) -> ProtocolResult<Self>
pub fn connect( address: impl ToSocketAddrs, protocol: impl LinoProtocol + 'static, ) -> ProtocolResult<Self>
Connects to the TCP address using protocol for every message.
Sourcepub fn connect_endpoint(
endpoint: &str,
protocol: impl LinoProtocol + 'static,
) -> ProtocolResult<Self>
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.
Sourcepub fn from_stream(
stream: IpcStream,
protocol: impl LinoProtocol + 'static,
) -> Self
pub fn from_stream( stream: IpcStream, protocol: impl LinoProtocol + 'static, ) -> Self
Talks over an already connected stream of any transport.
Sourcepub fn request(
&mut self,
document: &LinoDocument,
) -> ProtocolResult<LinoDocument>
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.
Sourcepub fn pending_notifications(&self) -> usize
pub fn pending_notifications(&self) -> usize
The number of pushes received and not yet taken by
receive_notification.
Sourcepub fn receive_notification(
&mut self,
timeout: Duration,
) -> ProtocolResult<Option<LinoDocument>>
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.
Sourcepub fn query(&mut self, query: &str) -> ProtocolResult<LinoDocument>
pub fn query(&mut self, query: &str) -> ProtocolResult<LinoDocument>
Runs a LiNo substitution query; the empty query reads every link.
Sourcepub fn query_lossless(&mut self, query: &str) -> ProtocolResult<LinoDocument>
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.
Sourcepub fn query_text(&mut self, query: &str) -> ProtocolResult<String>
pub fn query_text(&mut self, query: &str) -> ProtocolResult<String>
Like query, returning the reply as canonical text.
Sourcepub fn authenticate(&mut self, token: &str) -> ProtocolResult<u32>
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.