@@ -43,10 +43,20 @@ use crate::{Error, ErrorKind, Result};
4343/// | GCS | `storage-gcs` | `gcs` |
4444#[ derive( Clone , Debug ) ]
4545pub struct FileIO {
46+ builder : FileIOBuilder ,
47+
4648 inner : Arc < Storage > ,
4749}
4850
4951impl FileIO {
52+ /// Convert FileIO into [`FileIOBuilder`] which used to build this FileIO.
53+ ///
54+ /// This function is useful when you want serialize and deserialize FileIO across
55+ /// distributed systems.
56+ pub fn into_builder ( self ) -> FileIOBuilder {
57+ self . builder
58+ }
59+
5060 /// Try to infer file io scheme from path. See [`FileIO`] for supported schemes.
5161 ///
5262 /// - If it's a valid url, for example `s3://bucket/a`, url scheme will be used, and the rest of the url will be ignored.
@@ -134,7 +144,7 @@ impl FileIO {
134144}
135145
136146/// Builder for [`FileIO`].
137- #[ derive( Debug ) ]
147+ #[ derive( Clone , Debug ) ]
138148pub struct FileIOBuilder {
139149 /// This is used to infer scheme of operator.
140150 ///
@@ -165,7 +175,7 @@ impl FileIOBuilder {
165175 /// Fetch the scheme string.
166176 ///
167177 /// The scheme_str will be empty if it's None.
168- pub ( crate ) fn into_parts ( self ) -> ( String , HashMap < String , String > ) {
178+ pub fn into_parts ( self ) -> ( String , HashMap < String , String > ) {
169179 ( self . scheme_str . unwrap_or_default ( ) , self . props )
170180 }
171181
@@ -186,9 +196,10 @@ impl FileIOBuilder {
186196 }
187197
188198 /// Builds [`FileIO`].
189- pub fn build ( self ) -> crate :: Result < FileIO > {
190- let storage = Storage :: build ( self ) ?;
199+ pub fn build ( self ) -> Result < FileIO > {
200+ let storage = Storage :: build ( self . clone ( ) ) ?;
191201 Ok ( FileIO {
202+ builder : self ,
192203 inner : Arc :: new ( storage) ,
193204 } )
194205 }
0 commit comments