Skip to content

class flake::Wire ​

Abstract base class for all client-side wire implementations. More...

#include <platform/flake/Wire.h>

Public Functions ​

Name
Wire(const Wire & ) =deleted
Wire &operator=(const Wire & ) =deleted
Wire(Wire && ) =deleted
Wire &operator=(Wire && ) =deleted
virtual~Wire() =default
virtual ssize_tread(uint8_t * buf, size_t len) =0
Read data from the wire.
virtual ssize_twrite(const uint8_t * buf, size_t len) =0
Write data to the wire.
virtual intclose() =0
Close the wire and release associated resources.
virtual boolisOpen() =0
Check whether the wire is currently open.
virtual intopen() =0
Open (or re-open) the wire.
virtual intsecure() const =0
Query whether the wire uses a secure transport (e.g. TLS).
virtual intauthenticated() const =0
Query whether the peer has been authenticated.
virtual WireTypetype() const =0
Return the wire's transport category.
virtual intwaitReadable(uint32_t timeout_ms)
Block up to timeout_ms waiting until read may return data without blocking.
virtual intwaitWritable(uint32_t timeout_ms)
Block up to timeout_ms waiting until write may accept at least one byte without blocking. Default returns E_OK; semantics mirror waitReadable.
void *operator new(std::size_t n)
void *operator new(std::size_t n, const std::nothrow_t & )
voidoperator delete(void * p)
voidoperator delete(void * p, std::size_t n)

Protected Functions ​

Name
Wire() =default

Detailed Description ​

cpp
class flake::Wire;

Abstract base class for all client-side wire implementations.

Note: The class is non-copyable and non-movable by design.

Users create a concrete Wire (e.g. via flakeCreateTcpWire()) and pass it to flakeInitialize() to establish a connection to the router.

Public Functions Documentation ​

function Wire ​

cpp
Wire(
    const Wire & 
) =deleted

function operator= ​

cpp
Wire & operator=(
    const Wire & 
) =deleted

function Wire ​

cpp
Wire(
    Wire && 
) =deleted

function operator= ​

cpp
Wire & operator=(
    Wire && 
) =deleted

function ~Wire ​

cpp
virtual ~Wire() =default

function read ​

cpp
virtual ssize_t read(
    uint8_t * buf,
    size_t len
) =0

Read data from the wire.

Parameters:

  • buf Destination buffer.
  • len Maximum number of bytes to read.

Return: Number of bytes actually read, or a negative value on error.

function write ​

cpp
virtual ssize_t write(
    const uint8_t * buf,
    size_t len
) =0

Write data to the wire.

Parameters:

  • buf Source buffer.
  • len Number of bytes to write.

Return: Number of bytes actually written, or a negative value on error.

function close ​

cpp
virtual int close() =0

Close the wire and release associated resources.

Return: E_OK on success, or a negative error code.

function isOpen ​

cpp
virtual bool isOpen() =0

Check whether the wire is currently open.

Return: true if the wire is open, false otherwise.

function open ​

cpp
virtual int open() =0

Open (or re-open) the wire.

Return: E_OK on success, or a negative error code.

function secure ​

cpp
virtual int secure() const =0

Query whether the wire uses a secure transport (e.g. TLS).

Return: Non-zero if the transport is secure, 0 otherwise.

function authenticated ​

cpp
virtual int authenticated() const =0

Query whether the peer has been authenticated.

Return: Non-zero if authenticated, 0 otherwise.

function type ​

cpp
virtual WireType type() const =0

Return the wire's transport category.

Return: WireType::wtStream or WireType::wtDatagram.

function waitReadable ​

cpp
inline virtual int waitReadable(
    uint32_t timeout_ms
)

Block up to timeout_ms waiting until read may return data without blocking.

Return: E_OK if data may be available, E_TIMEOUT if the timeout elapsed without readiness, E_FAILED on error, E_NOT_CONNECTED if the wire closed.

Wires that own a real readiness primitive (a socket fd, an IPC ring's read-side semaphore) override this to honour the timeout. The default returns E_OK immediately so that legacy callers fall through to a blocking read; the worker-driven multiplex path (CoreWorker) only relies on overrides that wait properly.

< Operation completed successfully.

function waitWritable ​

cpp
inline virtual int waitWritable(
    uint32_t timeout_ms
)

Block up to timeout_ms waiting until write may accept at least one byte without blocking. Default returns E_OK; semantics mirror waitReadable.

< Operation completed successfully.

function operator new ​

cpp
static inline void * operator new(
    std::size_t n
)

All Wire subclasses share a single [WirePool](/embed/2.2.0/API/Namespaces/namespaceflake_1_1WirePool.md) slice (slot size = max sizeof, slot align = max alignof, count = FLAKE_MAX_WIRES). The base provides operator``new/delete; subclasses inherit. Returning nullptr from [WirePool::allocate](/embed/2.2.0/API/Namespaces/namespaceflake_1_1WirePool.md#function-allocate) signals pool exhaustion — the new-expression then yields nullptr and callers see E_NO_ALLOC. A subclass larger than the slot (IPCWire in a build without router) gets nullptr instead of overrunning the slot.

function operator new ​

cpp
static inline void * operator new(
    std::size_t n,
    const std::nothrow_t & 
)

function operator delete ​

cpp
static inline void operator delete(
    void * p
)

function operator delete ​

cpp
static inline void operator delete(
    void * p,
    std::size_t n
)

Protected Functions Documentation ​

function Wire ​

cpp
Wire() =default