Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Reader.Read API #49

Merged
merged 1 commit into from
Feb 28, 2025
Merged

Refactor Reader.Read API #49

merged 1 commit into from
Feb 28, 2025

Conversation

tigrannajaryan
Copy link
Collaborator

The API was inconsistent with Writer.Write() and was error-prone.

The new API is consistent with Writer.Write(). Both Writer.Write() and Reader.Read() now work with a Record that is an exporter field in the Writer/Reader struct. This makes it obvious that the Record is owned by the struct. Previously it was not clear if the pointer to the record returned by Reader.Read() was owned by the caller and could be modified and what it's lifetime was. Now it is more intuitively clear that the caller does not own the record and should not touch it and that the next Read() operation is going to overwrite it.

Also added pkg.ReadOptions to support reading options. The struct does not have any options yet, but options are coming in a future PR.

This is stacked on top of #48

Base automatically changed from tigran/statereset to main February 27, 2025 23:45
The API was inconsistent with Writer.Write() and was error-prone.

The new API is consistent with Writer.Write(). Both Writer.Write()
and Reader.Read() now work with a Record that is an exporter field
in the Writer/Reader struct. This makes it obvious that the Record
is owned by the struct. Previously it was not clear if the
pointer to the record returned by Reader.Read() was owned by the
caller and could be modified and what it's lifetime was.
Now it is more intuitively clear that the caller does not own the
record and should not touch it and that the next Read() operation
is going to overwrite it.

Also added pkg.ReadOptions to support reading options. The struct
does not have any options yet, but options are coming in a future PR.
@tigrannajaryan tigrannajaryan merged commit c5c038a into main Feb 28, 2025
2 checks passed
@tigrannajaryan tigrannajaryan deleted the tigran/readerapi branch February 28, 2025 01:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants