trait ReadColumn
, to read a single column from a RowRef
#789
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of Changes
This commit defines
trait ReadColumn
, which is implemented for types that can be stored in a table column and can be read out of said table column.Its interesting method is
read_column(row: RowRef<'_>, idx: usize) -> Result<Self, TypeError>
, which attempts to read theidx
th column ofrow
as a value of typeSelf
, returning aTypeError
if the row in question does not have the appropriate types.ReadColumn
is implemented for Rust equivalents of all non-compoundAlgebraicType
s, i.e. integers, floats,bool
andString
. It is also implemented for all SATS value types, including those which represent values of compound types, i.e.AlgebraicValue
,ProductValue
,SumValue
,ArrayValue
andMapValue
.Note that this commit does not use the
ReadColumn
interface anywhere, except in tests. Follow-ups will useReadColumn
in various places, including:API and ABI breaking changes
None.
Expected complexity level and risk
3: non-trivial uses of
unsafe
; new uses of existingbflatn_from
serialization.