google_cloud_bigquery/write/arrow/
writer.rs1use super::{BufferedWriter, CommittedWriter, PendingWriter};
16use crate::model::ArrowSchema;
17use crate::model::write_stream::Type;
18use crate::write::transport::Transport;
19use std::sync::Arc;
20
21pub(crate) mod sealed {
22 use super::*;
23
24 pub trait Writer {
25 const STREAM_TYPE: Type;
26 fn build(inner: Arc<Transport>, write_stream: String, schema: ArrowSchema) -> Self;
27 }
28
29 impl Writer for PendingWriter {
30 const STREAM_TYPE: Type = Type::Pending;
31
32 fn build(inner: Arc<Transport>, write_stream: String, schema: ArrowSchema) -> Self {
33 Self::new(inner, write_stream, schema)
34 }
35 }
36
37 impl Writer for CommittedWriter {
38 const STREAM_TYPE: Type = Type::Committed;
39
40 fn build(inner: Arc<Transport>, write_stream: String, schema: ArrowSchema) -> Self {
41 Self::new(inner, write_stream, schema)
42 }
43 }
44
45 impl Writer for BufferedWriter {
46 const STREAM_TYPE: Type = Type::Buffered;
47
48 fn build(inner: Arc<Transport>, write_stream: String, schema: ArrowSchema) -> Self {
49 Self::new(inner, write_stream, schema)
50 }
51 }
52}
53
54pub trait Writer: sealed::Writer + Sized {}
58
59impl<T: sealed::Writer + Sized> Writer for T {}