LibJuno 1.0.4
LibJuno is a lightweight C11 library designed specifically for embedded systems.
Loading...
Searching...
No Matches
JUNO_UDP_API_TAG Struct Reference

Vtable defining the UDP socket module interface. More...

#include <udp_api.h>

Data Fields

JUNO_STATUS_T(* Send )(JUNO_UDP_ROOT_T *ptRoot, const UDP_THREAD_MSG_T *ptMsg)
 Send exactly one UDP_THREAD_MSG_T datagram.
 
JUNO_STATUS_T(* Receive )(JUNO_UDP_ROOT_T *ptRoot, UDP_THREAD_MSG_T *ptMsg)
 Receive exactly one UDP_THREAD_MSG_T datagram.
 
JUNO_STATUS_T(* Free )(JUNO_UDP_ROOT_T *ptRoot)
 Release all resources held by the module (RAII cleanup).
 

Detailed Description

Vtable defining the UDP socket module interface.

Every concrete UDP implementation (Linux POSIX, test double) provides a statically allocated JUNO_UDP_API_T whose function pointers are wired into a root by JunoUdp_LinuxInit. All operations take the module root as their first argument and return JUNO_STATUS_T for uniform error propagation.

This vtable expresses capabilities only (the "Rust trait" pattern). Resource acquisition (socket open) is performed by the platform init function (JunoUdp_LinuxInit) via RAII; it is not part of the vtable.

Field Documentation

◆ Free

JUNO_STATUS_T(* JUNO_UDP_API_TAG::Free) (JUNO_UDP_ROOT_T *ptRoot)

Release all resources held by the module (RAII cleanup).

Closes the socket and resets the internal socket descriptor. Idempotent: safe to call even if the socket was never opened or has already been freed. Returns JUNO_STATUS_SUCCESS in that case.

Parameters
ptRootModule root instance; must be non-NULL.
Returns
JUNO_STATUS_SUCCESS on success; non-zero on failure.

◆ Receive

JUNO_STATUS_T(* JUNO_UDP_API_TAG::Receive) (JUNO_UDP_ROOT_T *ptRoot, UDP_THREAD_MSG_T *ptMsg)

Receive exactly one UDP_THREAD_MSG_T datagram.

Parameters
ptRootModule root instance; socket must be open.
ptMsgOutput buffer; must be non-NULL.
Returns
JUNO_STATUS_SUCCESS on success; JUNO_STATUS_TIMEOUT_ERROR on timeout (normal condition, failure handler not invoked); non-zero on other failures.

◆ Send

JUNO_STATUS_T(* JUNO_UDP_API_TAG::Send) (JUNO_UDP_ROOT_T *ptRoot, const UDP_THREAD_MSG_T *ptMsg)

Send exactly one UDP_THREAD_MSG_T datagram.

Parameters
ptRootModule root instance; socket must be open.
ptMsgMessage to send; must be non-NULL and valid for the call.
Returns
JUNO_STATUS_SUCCESS on success; non-zero on failure.

The documentation for this struct was generated from the following file: