pub struct BufferedSocket { /* private fields */ }
Expand description

An adapter around a raw Socket that directly handles buffering and conversion from/to wayland messages

Implementations

Wrap a Socket into a Buffered Socket

Get direct access to the underlying socket

Retrieve ownership of the underlying Socket

Any leftover content in the internal buffers will be lost

Flush the contents of the outgoing buffer into the socket

Write a message to the outgoing buffer

This method may flush the internal buffer if necessary (if it is full).

If the message is too big to fit in the buffer, the error Error::Sys(E2BIG) will be returned.

Try to fill the incoming buffers of this socket, to prepare a new round of parsing.

Read and deserialize a single message from the incoming buffers socket

This method requires one closure that given an object id and an opcode, must provide the signature of the associated request/event, in the form of a &'static [ArgumentType]. If it returns None, meaning that the couple object/opcode does not exist, an error will be returned.

There are 3 possibilities of return value:

  • Ok(Ok(msg)): no error occurred, this is the message
  • Ok(Err(e)): either a malformed message was encountered or we need more data, in the latter case you need to try calling fill_incoming_buffers().
  • Err(e): an I/O error occurred reading from the socked, details are in e (this can be a “wouldblock” error, which just means that no message is available to read)

Read and deserialize messages from the socket

This method requires two closures:

  • The first one, given an object id and an opcode, must provide the signature of the associated request/event, in the form of a &'static [ArgumentType]. If it returns None, meaning that the couple object/opcode does not exist, the parsing will be prematurely interrupted and this method will return a MessageParseError::Malformed error.
  • The second closure is charged to process the parsed message. If it returns false, the iteration will be prematurely stopped.

In both cases of early stopping, the remaining unused data will be left in the buffers, and will start to be processed at the next call of this method.

There are 3 possibilities of return value:

  • Ok(Ok(n)): no error occurred, n messages where processed
  • Ok(Err(MessageParseError::Malformed)): a malformed message was encountered (this is a protocol error and is supposed to be fatal to the connection).
  • Err(e): an I/O error occurred reading from the socked, details are in e (this can be a “wouldblock” error, which just means that no message is available to read)

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.