Struct Protocol

Source
pub struct Protocol<C> { /* private fields */ }
Expand description

Connection wrapper to process channel requests and responses.

This provides a low-level interface to communicate with the Mercurial command server.

Implementations§

Source§

impl<C> Protocol<C>

Source

pub fn new(conn: C) -> Self

Creates a new Protocol that wraps the given connection.

Source

pub fn into_connection(self) -> C

Unwraps the underlying Connection.

Source§

impl<C> Protocol<C>
where C: Connection,

Source

pub async fn send_command(&mut self, cmd: impl Into<Bytes>) -> Result<()>

Sends the command of no argument without waiting for response.

This is equivalent to OneShotRequest::start() of tokio-hglib 0.2. For MessageLoop::start(), call this function and fetch responses.

Source

pub async fn send_command_with_args( &mut self, cmd: impl Into<Bytes>, packed_args: impl Into<Bytes>, ) -> Result<()>

Sends the command and arguments without waiting for response.

This is equivalent to OneShotRequest::start_with_args() of tokio-hglib 0.2. For MessageLoop::start_with_args(), call this function and fetch responses.

Source

pub async fn send_data(&mut self, data: impl Into<Bytes>) -> Result<()>

Sends the given data back to the server.

For MessageLoop::resume_with_data() of tokio-hglib 0.2, call this function and fetch responses.

Source

pub async fn query(&mut self, cmd: impl Into<Bytes>) -> Result<Bytes>

Sends the command of no argument, and fetches the result data.

This is equivalent to OneShotQuery::start() of tokio-hglib 0.2.

Source

pub async fn query_with_args( &mut self, cmd: impl Into<Bytes>, packed_args: impl Into<Bytes>, ) -> Result<Bytes>

Sends the command and arguments, and fetches the result data.

This is equivalent to OneShotQuery::start_with_args() of tokio-hglib 0.2.

Source

pub async fn fetch_response(&mut self) -> Result<ChannelMessage>

Fetches response message from the server.

This is equivalent to MessageLoop::resume() of tokio-hglib 0.2.

Trait Implementations§

Source§

impl<C> AsRawFd for Protocol<C>
where C: AsRawFd,

Source§

fn as_raw_fd(&self) -> RawFd

Extracts the raw file descriptor. Read more
Source§

impl<C: Debug> Debug for Protocol<C>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<C> Freeze for Protocol<C>
where C: Freeze,

§

impl<C> RefUnwindSafe for Protocol<C>
where C: RefUnwindSafe,

§

impl<C> Send for Protocol<C>
where C: Send,

§

impl<C> Sync for Protocol<C>
where C: Sync,

§

impl<C> Unpin for Protocol<C>
where C: Unpin,

§

impl<C> UnwindSafe for Protocol<C>
where C: UnwindSafe,

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