Переглянути джерело

Add BingenStream to the codecs such that streams can be typed under the interface

Matt Bolt 5 місяців тому
батько
коміт
c4916b5993
1 змінених файлів з 10 додано та 0 видалено
  1. 10 0
      core/pkg/opencost/opencost_codecs.go

+ 10 - 0
core/pkg/opencost/opencost_codecs.go

@@ -165,6 +165,16 @@ func resolveType(t string) (pkg string, name string, isPtr bool) {
 //  Stream Helpers
 //  Stream Helpers
 //--------------------------------------------------------------------------
 //--------------------------------------------------------------------------
 
 
+// BingenStream is the stream interface for all streamable types
+type BingenStream interface {
+	// Stream returns the iterator which will stream each field of the target type and
+	// return the field info as well as the value.
+	Stream() iter.Seq2[BingenFieldInfo, *BingenValue]
+
+	// Close will close any dynamic io.Readers used to stream in the fields
+	Close()
+}
+
 // BingenValue contains the value of a field as well as any index/key associated with that value.
 // BingenValue contains the value of a field as well as any index/key associated with that value.
 type BingenValue struct {
 type BingenValue struct {
 	Value any
 	Value any