LibJuno 1.0.4
LibJuno is a lightweight C11 library designed specifically for embedded systems.
Loading...
Searching...
No Matches
async_io_api.h
Go to the documentation of this file.
1/*
2 MIT License
3
4 Copyright (c) 2025 Robin A. Onsay
5
6 Permission is hereby granted, free of charge, to any person obtaining
7 a copy of this software and associated documentation files
8 (the "Software"), to deal in the Software without restriction,
9 including without limitation the rights to use, copy, modify, merge,
10 publish, distribute, sublicense, and/or sell copies of the Software,
11 and to permit persons to whom the Software is furnished to do so,
12 subject to the following conditions:
13
14 The above copyright notice and this permission notice shall be
15 included in all copies or substantial portions of the Software.
16*/
17
32#ifndef JUNO_ASYNC_IO_API_H
33#define JUNO_ASYNC_IO_API_H
34#include "juno/status.h"
35#include "juno/module.h"
36#include "juno/time/time_api.h"
37#include <stdbool.h>
38#ifdef __cplusplus
39extern "C"
40{
41#endif
42
44
45typedef struct JUNO_ASYNC_IO_ROOT_TAG JUNO_ASYNC_IO_ROOT_T;
46
47// @{"req": ["REQ-IO-001"]}
49
51{
53 // @{"req": ["REQ-IO-002"]}
54 JUNO_STATUS_T (*Read)(JUNO_ASYNC_IO_ROOT_T *ptIo, char *pcBuff, size_t *pzBuffSize);
56 // @{"req": ["REQ-IO-003"]}
57 JUNO_STATUS_T (*TryRead)(JUNO_ASYNC_IO_ROOT_T *ptIo, char *pcBuff, size_t *pzBuffSize, JUNO_TIME_MICROS_T iTimeoutUs);
59 // @{"req": ["REQ-IO-004"]}
60 JUNO_STATUS_T (*ReadUntil)(JUNO_ASYNC_IO_ROOT_T *ptIo, char *pcBuff, size_t *pzBuffSize, const char *pcStopChars, size_t zSizeStopChars);
62 // @{"req": ["REQ-IO-005"]}
63 JUNO_STATUS_T (*TryReadUntil)(JUNO_ASYNC_IO_ROOT_T *ptIo, char *pcBuff, size_t *pzBuffSize, const char *pcStopChars, size_t zSizeStopChars, JUNO_TIME_MICROS_T iTimeoutUs);
65 // @{"req": ["REQ-IO-006"]}
66 JUNO_STATUS_T (*Write)(JUNO_ASYNC_IO_ROOT_T *ptIo, const void *pvBuff, size_t *pzBuffSize);
68 // @{"req": ["REQ-IO-007"]}
69 JUNO_STATUS_T (*TryWrite)(JUNO_ASYNC_IO_ROOT_T *ptIo, const void *pvBuff, size_t *pzBuffSize, JUNO_TIME_MICROS_T iTimeoutUs);
71 // @{"req": ["REQ-IO-008"]}
72 JUNO_STATUS_T (*Poll)(JUNO_ASYNC_IO_ROOT_T *ptIo, JUNO_TIME_MICROS_T iTimeoutUs, bool *pbHasData);
73};
74
75#ifdef __cplusplus
76}
77#endif
78#endif // JUNO_ASYNC_IO_API_H
struct JUNO_ASYNC_IO_ROOT_TAG JUNO_ASYNC_IO_ROOT_T
Definition async_io_api.h:45
#define JUNO_MODULE_EMPTY
Helper for module definitions with no additional members.
Definition module.h:87
#define JUNO_MODULE_ROOT(API_T,...)
Implement a module root struct containing ptApi and failure fields.
Definition module.h:129
int32_t JUNO_STATUS_T
Canonical status type for LibJuno functions.
Definition status.h:51
uint64_t JUNO_TIME_MICROS_T
Microseconds count type.
Definition time_api.h:77
Module system and dependency injection primitives for LibJuno.
Status codes and failure-handling helpers for LibJuno.
Definition async_io_api.h:51
JUNO_STATUS_T(* Poll)(JUNO_ASYNC_IO_ROOT_T *ptIo, JUNO_TIME_MICROS_T iTimeoutUs, bool *pbHasData)
Poll for input readiness within timeout; sets pbHasData.
Definition async_io_api.h:72
JUNO_STATUS_T(* Read)(JUNO_ASYNC_IO_ROOT_T *ptIo, char *pcBuff, size_t *pzBuffSize)
Read up to *pzBuffSize bytes; updates size with bytes read.
Definition async_io_api.h:54
JUNO_STATUS_T(* ReadUntil)(JUNO_ASYNC_IO_ROOT_T *ptIo, char *pcBuff, size_t *pzBuffSize, const char *pcStopChars, size_t zSizeStopChars)
Read until any stop character is received (size updated).
Definition async_io_api.h:60
JUNO_STATUS_T(* TryReadUntil)(JUNO_ASYNC_IO_ROOT_T *ptIo, char *pcBuff, size_t *pzBuffSize, const char *pcStopChars, size_t zSizeStopChars, JUNO_TIME_MICROS_T iTimeoutUs)
Try to read until stop character or timeout.
Definition async_io_api.h:63
JUNO_STATUS_T(* TryWrite)(JUNO_ASYNC_IO_ROOT_T *ptIo, const void *pvBuff, size_t *pzBuffSize, JUNO_TIME_MICROS_T iTimeoutUs)
Try to write with timeout; updates size with bytes written.
Definition async_io_api.h:69
JUNO_STATUS_T(* Write)(JUNO_ASYNC_IO_ROOT_T *ptIo, const void *pvBuff, size_t *pzBuffSize)
Write up to *pzBuffSize bytes; updates size with bytes written.
Definition async_io_api.h:66
JUNO_STATUS_T(* TryRead)(JUNO_ASYNC_IO_ROOT_T *ptIo, char *pcBuff, size_t *pzBuffSize, JUNO_TIME_MICROS_T iTimeoutUs)
Try to read with timeout; returns when data available or timeout.
Definition async_io_api.h:57
Juno Time module API and common time math helpers.