typed_arrow_dyn/
schema.rs1use std::sync::Arc;
4
5use arrow_array::RecordBatch;
6use arrow_schema::{Schema, SchemaRef};
7
8use crate::{DynRowView, DynRowViews, DynViewError};
9
10#[derive(Debug, Clone)]
12pub struct DynSchema {
13 pub schema: SchemaRef,
15}
16
17impl DynSchema {
18 #[must_use]
20 pub fn new(schema: Schema) -> Self {
21 Self {
22 schema: Arc::new(schema),
23 }
24 }
25
26 #[must_use]
28 pub fn from_ref(schema: SchemaRef) -> Self {
29 Self { schema }
30 }
31
32 pub fn iter_views<'a>(
37 &'a self,
38 batch: &'a RecordBatch,
39 ) -> Result<DynRowViews<'a>, DynViewError> {
40 crate::view::DynRowViews::new(batch, self.schema.as_ref())
41 }
42
43 pub fn view_at<'a>(
49 &'a self,
50 batch: &'a RecordBatch,
51 row: usize,
52 ) -> Result<DynRowView<'a>, DynViewError> {
53 crate::view::view_batch_row(self, batch, row)
54 }
55}