4#ifndef PROTOCORE_EDGE_FETCH_H
5#define PROTOCORE_EDGE_FETCH_H
36 int (*
open)(
void *
ctx,
const char *host, uint16_t port, uint32_t timeout_ms);
38 embed_bool (*
send)(
void *
ctx,
int cid,
const void *data,
size_t len);
39 size_t (*
read)(
void *
ctx,
int cid, uint8_t *buf,
size_t cap);
48 EDGE_FETCH_STATUS_PENDING,
49 EDGE_FETCH_STATUS_DONE,
50 EDGE_FETCH_STATUS_OVERSIZE,
51 EDGE_FETCH_STATUS_FAILED,
77 embed_bool (*
edge_resp_complete)(
const uint8_t *,
const uint8_t *, size_t, embed_bool,
size_t *);
93 uint16_t port,
const void *request,
size_t req_len, uint32_t now_ms);
120 embed_bool conn_closed,
size_t *head_len);
126 .edge_resp_complete =
#define PROTOCORE_EDGE_FETCH_BUF
void protocore_edge_fetcher_begin(const uint8_t *work, EdgeFetch *f, const EdgeFetchTransport *t, const char *host, uint16_t port, const void *request, size_t req_len, uint32_t now_ms)
Open the origin connection and park request; begin the fetch. Sets .
EMBED_ENUM_BYTE(EdgeFetchStatus, EDGE_FETCH_STATUS_PENDING, EDGE_FETCH_STATUS_DONE, EDGE_FETCH_STATUS_OVERSIZE, EDGE_FETCH_STATUS_FAILED,)
Fetch progress.
EdgeFetchStatus protocore_edge_fetcher_pump(uint8_t *work, EdgeFetch *f, const EdgeFetchTransport *t, uint32_t now_ms)
Drain available bytes and advance. On DONE the response is parsed .
embed_bool protocore_edge_fetcher_edge_resp_complete(const uint8_t *work, const uint8_t *buf, size_t len, embed_bool conn_closed, size_t *head_len)
Is the accumulated response complete? (headers terminated + body .
void protocore_edge_fetcher_end(const uint8_t *work, EdgeFetch *f, const EdgeFetchTransport *t)
Release the transport connection (idempotent).
#define PROTOCORE_UNUSED
Suppress the unused warning. Every module ends in a namespace most callers only partly use.
#define PROTOCORE_NS_LAYOUT(T,...)
Pin every dispatch slot of a table that is nothing but function pointers.
#define PROTOCORE_NS
Storage for a dispatch table. The const is load bearing.
Dispatch table. Addressed by offset, so the layout is asserted below.
void(* begin)(const uint8_t *, EdgeFetch *, const EdgeFetchTransport *, const char *, uint16_t, const void *, size_t, uint32_t)
EdgeFetchStatus(* pump)(uint8_t *, EdgeFetch *, const EdgeFetchTransport *, uint32_t)
embed_bool(* edge_resp_complete)(const uint8_t *, const uint8_t *, size_t, embed_bool, size_t *)
void(* end)(const uint8_t *, EdgeFetch *, const EdgeFetchTransport *)
The origin transport, bound to protocore_client on the device and a mock in host tests.
size_t(* read)(void *ctx, int cid, uint8_t *buf, size_t cap)
0 = nothing available right now
embed_bool(* connected)(void *ctx, int cid)
step the open along; true once it is up
int(* open)(void *ctx, const char *host, uint16_t port, uint32_t timeout_ms)
cid >= 0, or < 0 on failure
void(* close)(void *ctx, int cid)
embed_bool(* send)(void *ctx, int cid, const void *data, size_t len)
embed_bool(* closed)(void *ctx, int cid)
true once the origin closed its side
One in-flight origin fetch (fixed-size, zero-heap).
uint32_t got
bytes accumulated
embed_bool sent
the request reached the transport, so buf now takes the response
uint8_t buf[PROTOCORE_EDGE_FETCH_BUF]
uint32_t req_len
request bytes parked at the head of buf until the connection is up
int status
HTTP status (valid when DONE).