Phosphor
Qt6 / Wayland library suite for window-management tools
Loading...
Searching...
No Matches
PhosphorChannel Namespace Reference

Classes

struct  AcceptOptions
 What a reader takes. More...
class  RingWriter
class  RingReader
class  StreamWriter
 The writing end of one channel of a stream. More...
class  StreamReader
 The reading end of one channel of a stream. More...
class  Stream

Enumerations

enum class  WriteResult { Written , WouldBlock , TooLarge , Closed }
enum class  ReadResult { Frame , Empty , Closed , Corrupt }

Functions

PHOSPHORCHANNEL_EXPORT bool validCodec (std::string_view codec)
 1 to MaxCodecBytes of printable ASCII without spaces, such as "afterglow.state.v1".
PHOSPHORCHANNEL_EXPORT std::string versionMismatch (std::uint32_t theirs)
 The message for two protocol versions that do not match.
PHOSPHORCHANNEL_EXPORT bool offerRing (int socket, RingWriter &ring, int timeoutMs, std::string *error)
 Sends ring over socket and waits for the answer.
PHOSPHORCHANNEL_EXPORT std::unique_ptr< RingReader > acceptRing (int socket, const AcceptOptions &options, int timeoutMs, std::string *error)
 Receives a ring over socket, maps it, and answers whether it took it.

Variables

constexpr std::uint32_t ProtocolVersion = 1
 Covers the handshakes, the stream's packets and the ring's layout.
constexpr std::size_t MaxCodecBytes = 64
 The longest codec tag, in bytes.

Enumeration Type Documentation

◆ ReadResult

enum class PhosphorChannel::ReadResult
strong
Enumerator
Frame 
Empty 

No frame waits now. Wait until the transport says that one came.

Closed 

The writer closed the channel, or went away, and every frame that it wrote was read.

Corrupt 

The other process broke the protocol, so nothing after it can be trusted.

Close the channel.

◆ WriteResult

enum class PhosphorChannel::WriteResult
strong
Enumerator
Written 
WouldBlock 

The channel is full.

Nothing was written: the writer keeps the frame, or merges it with the next one, and waits until the transport says that it may write again.

TooLarge 

The frame can never fit this channel.

Closed 

No frame can go any more: the reader closed the channel, the other process went away, or the transport failed.

Function Documentation

◆ acceptRing()

PHOSPHORCHANNEL_EXPORT std::unique_ptr< RingReader > PhosphorChannel::acceptRing ( int socket,
const AcceptOptions & options,
int timeoutMs,
std::string * error )

Receives a ring over socket, maps it, and answers whether it took it.

Nullptr with error when it was refused or failed.

◆ offerRing()

PHOSPHORCHANNEL_EXPORT bool PhosphorChannel::offerRing ( int socket,
RingWriter & ring,
int timeoutMs,
std::string * error )

Sends ring over socket and waits for the answer.

A ring is offered once, whatever the answer. False with error when the reader refused it, the socket failed or the time ran out.

◆ validCodec()

PHOSPHORCHANNEL_EXPORT bool PhosphorChannel::validCodec ( std::string_view codec)

1 to MaxCodecBytes of printable ASCII without spaces, such as "afterglow.state.v1".

◆ versionMismatch()

PHOSPHORCHANNEL_EXPORT std::string PhosphorChannel::versionMismatch ( std::uint32_t theirs)

The message for two protocol versions that do not match.

Variable Documentation

◆ MaxCodecBytes

std::size_t PhosphorChannel::MaxCodecBytes = 64
inlineconstexpr

The longest codec tag, in bytes.

◆ ProtocolVersion

std::uint32_t PhosphorChannel::ProtocolVersion = 1
inlineconstexpr

Covers the handshakes, the stream's packets and the ring's layout.

Two ends with different versions refuse each other, with a message that names both. The codec tag, not this, versions a payload.