// The result surface: Rows, an iterator of named-column Row values. The // executor materializes the result set and Rows streams it from the buffer // (same contract as the Rust engine's lazy Rows).
package gql import ( ) // Row is one result row: named columns mapped to values. The column slice // is shared across every row of a result. type Row struct { columns []string values []value.Value } // Get returns the value of column name; ok is false when absent. func ( Row) ( string) (value.Value, bool) { for , := range .columns { if == { return .values[], true } } return value.Value{}, false } // GetAt returns the value at output position i; ok is false out of range. func ( Row) ( int) (value.Value, bool) { if < 0 || >= len(.values) { return value.Value{}, false } return .values[], true } // Values is the row's values in output-column order. func ( Row) () []value.Value { return .values } // Columns is the output column names, in order. func ( Row) () []string { return .columns } // Rows iterates a query's result rows. type Rows struct { columns []string rows [][]value.Value i int } // newRows wraps the executor's output buffer. func newRows( []string, [][]value.Value) *Rows { return &Rows{columns: , rows: } } // Columns is the output column names, in order. func ( *Rows) () []string { return .columns } // Next pulls the next row; ok is false when the result is exhausted. func ( *Rows) () (Row, bool) { if .i >= len(.rows) { return Row{}, false } := Row{columns: .columns, values: .rows[.i]} .i++ return , true } // NextBatch pulls up to n rows (fewer if the result is exhausted). func ( *Rows) ( int) []Row { := make([]Row, 0, ) for range { , := .Next() if ! { break } = append(, ) } return } // All iterates the remaining rows (range-over-func). func ( *Rows) () iter.Seq[Row] { return func( func(Row) bool) { for { , := .Next() if ! || !() { return } } } }