go_wireproto/README.md
2025-09-30 15:49:54 -04:00

107 lines
5.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Reference
In addition to the documentation found in this document and [the
specification](https://wireproto.io/), library usage documentation can
be found at [the Golang module documentation
page](https://pkg.go.dev/r00t2.io/wireproto):
# License
This library is licensed for use, inclusion, and distribution under the
["3-Clause BSD" license](https://opensource.org/license/bsd-3-clause).
Copyright (c) 2024 Brent Saner (r00t^2).
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# TODO
The following are a wishlist or things planned that may come in later
versions.
- More clear errors
- Currently during e.g. `UnmarshalBinary` calls, just an `io.EOF`
will be returned if the buffer is exhausted early. This may be
able to be a little more context-helpful by using the `Err*`
errors.
- Confirmation of read/write sizes in buffers
- The sizes they **should** be are known, theres no reason to not
confirm it.
- Goroutines
- This of course wont work for serializing and keeping **order**
of children (e.g. RG ⇒ Record); thatd still need to be ordered,
but it will allow for parallel parsing **of** those children.
Should benchmark, though; it may not be worth it.
- `context.Context` support for `Read*` and `Write*` funcs
- This is a relatively low priority as the passed `net.Conn` will
likely return an error if its own context is canceled. This can
be handled in the caller downstream.
- Better/more strict interfaces
- Maps for generic should have `any`, not `interface{}` values
- FVP should have its own method to a map\[string\]\[\]byte return
value
- "Getters and Setters" (ew, I know, but compromises are made with
flexibility)
- `.Append*()` methods to append any type to any parent type. e.g.
`<Response>.AppendFVP(<FieldValuePair>)` would append an FVP to
the most recent ResponseRecord to the most recent
ResponseRecordGroup (or create if they dont exist),
`<Response>.AppendRecord(…​)` for appending a record to most
recent record group etc.
- `.Get()`/`.Set()` on a Response/Request to get/set a slice of
values (`<FieldValue>`) from filter criteria as struct (e.g.
field name, how many, first X, last X, etc.)
- `.GetPath*()` and `.SetPath*()` to use
**\[`RG_N`\[`R_N`\[`FVP_N`\]\]\]** indexing (e.g. `0, 0, 0` for
RecordGroup 0/Record 0/FVP 0, `1, 3, 5` for RecordGroup 1/Record
3/FVP 5, etc.) multidimentional indexing
- Allow specific lookups/sets by multidimentional array index
to return FVP (`.GetIndex(idx)` where `idx` is a fixed-size
array of dimensions for objects children paths); e.g.
`<Response>.GetIndex(idx)`, `idx` is `[3]int` and returns
FVP)
- Allow lookups/sets by variable length index
(`.GetIndexDynamic(idx)`, where `idx` is a `1` to `n`-size
slice of dimensions for objects children paths (e.g.
`<Response>.GetIndexDynamic([]int{0, 0})` returns
`any(<Record>)` but
`<Response>.GetIndexDynamic([]int{0, 0, 0})` returns
`any(FieldValuePair)`)
- negative value indicates **all** children
- Lookups/sets at fixed levels (e.g.
`<RecordGroup>.GetRecord(idx)`, `idx` is `[1]int`, but
`<RecordGroup>.GetFVP(idx)`, `idx` is `[2]int`) for type
safety
- All objects have `.ID()` that returns their
index/"path"/"key" from the root, and `.Index()` that
returns their index within their immediate parent
- This obviously requires a `.Resolve()` first