diff options
author | Lizzy Fleckenstein <lizzy@vlhl.dev> | 2024-07-13 12:51:05 +0200 |
---|---|---|
committer | Lizzy Fleckenstein <lizzy@vlhl.dev> | 2024-07-13 12:51:05 +0200 |
commit | 591232eba1809643df1f4a6075ff9581b8bb2f7a (patch) | |
tree | 92e2c464158d03ef9c83f153ba5b88c39581d9f8 /src/ser.h | |
parent | 95283d70eee749d984b2ca07c0b61d39f9bb350d (diff) |
move headers to src
Signed-off-by: Lizzy Fleckenstein <lizzy@vlhl.dev>
Diffstat (limited to 'src/ser.h')
-rw-r--r-- | src/ser.h | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/ser.h b/src/ser.h new file mode 100644 index 0000000..374e5d9 --- /dev/null +++ b/src/ser.h @@ -0,0 +1,51 @@ +// SPDX-FileCopyrightText: 2024 Lizzy Fleckenstein <lizzy@vlhl.dev> +// +// SPDX-License-Identifier: AGPL-3.0-or-later + +#ifndef SER_H +#define SER_H + +#include <stdbool.h> +#include <stddef.h> +#include <stdint.h> +#include "str.h" + +// ser + +void ser_bytes(strbuf *w, void *x, size_t len); + +void ser_bool(strbuf *w, bool x); +void ser_str(strbuf *w, str x); + +void ser_u8(strbuf *w, uint8_t x); +void ser_i8(strbuf *w, int8_t x); + +void ser_u16(strbuf *w, uint16_t x); +void ser_i16(strbuf *w, int16_t x); + +void ser_u32(strbuf *w, uint32_t x); +void ser_i32(strbuf *w, int32_t x); + +void ser_u64(strbuf *w, uint64_t x); +void ser_i64(strbuf *w, int64_t x); + +// deser + +bool deser_bytes(str *r, void *buf, size_t len); + +bool deser_bool(str *r, bool *buf); +bool deser_str(str *r, str *buf); // returns slice! + +bool deser_u8(str *r, uint8_t *buf); +bool deser_i8(str *r, int8_t *buf); + +bool deser_u16(str *r, uint16_t *buf); +bool deser_i16(str *r, int16_t *buf); + +bool deser_u32(str *r, uint32_t *buf); +bool deser_i32(str *r, int32_t *buf); + +bool deser_u64(str *r, uint64_t *buf); +bool deser_i64(str *r, int64_t *buf); + +#endif |