@@ -303,17 +303,28 @@ impl FileRead for opendal::Reader {
303303/// Input file is used for reading from files.
304304#[ derive( Debug ) ]
305305pub struct InputFile {
306- /// todo doc
307- pub storage : Arc < dyn Storage > ,
308- // Absolution path of file.
309- /// todo doc
310- pub path : String ,
311- // todo should remove this? Should always pass down a full path
312- // // Relative path of file to uri, starts at [`relative_path_pos`]
313- // relative_path_pos: usize,
306+ /// Storage backend for this input file.
307+ storage : Arc < dyn Storage > ,
308+ /// Absolute path to the file.
309+ path : String ,
314310}
315311
316312impl InputFile {
313+ /// Creates a new input file.
314+ ///
315+ /// # Arguments
316+ ///
317+ /// * `storage` - The storage backend to use
318+ /// * `path` - Absolute path to the file
319+ pub fn new ( storage : Arc < dyn Storage > , path : String ) -> Self {
320+ Self { storage, path }
321+ }
322+
323+ /// Returns the storage backend for this input file.
324+ pub fn storage ( & self ) -> & Arc < dyn Storage > {
325+ & self . storage
326+ }
327+
317328 /// Absolute path to root uri.
318329 pub fn location ( & self ) -> & str {
319330 & self . path
@@ -386,20 +397,31 @@ impl FileWrite for Box<dyn FileWrite> {
386397 }
387398}
388399
389- /// Output file is used for writing to files..
400+ /// Output file is used for writing to files.
390401#[ derive( Debug ) ]
391402pub struct OutputFile {
392- /// todo fix pub qualifier
393- pub storage : Arc < dyn Storage > ,
394- // Absolution path of file.
395- /// todo fix pub qualifier
396- pub path : String ,
397- // todo should always pass down a full path
398- // // Relative path of file to uri, starts at [`relative_path_pos`]
399- // relative_path_pos: usize,
403+ /// Storage backend for this output file.
404+ storage : Arc < dyn Storage > ,
405+ /// Absolute path to the file.
406+ path : String ,
400407}
401408
402409impl OutputFile {
410+ /// Creates a new output file.
411+ ///
412+ /// # Arguments
413+ ///
414+ /// * `storage` - The storage backend to use
415+ /// * `path` - Absolute path to the file
416+ pub fn new ( storage : Arc < dyn Storage > , path : String ) -> Self {
417+ Self { storage, path }
418+ }
419+
420+ /// Returns the storage backend for this output file.
421+ pub fn storage ( & self ) -> & Arc < dyn Storage > {
422+ & self . storage
423+ }
424+
403425 /// Relative path to root uri.
404426 pub fn location ( & self ) -> & str {
405427 & self . path
@@ -419,10 +441,7 @@ impl OutputFile {
419441
420442 /// Converts into [`InputFile`].
421443 pub fn to_input_file ( self ) -> InputFile {
422- InputFile {
423- storage : self . storage ,
424- path : self . path ,
425- }
444+ InputFile :: new ( self . storage , self . path )
426445 }
427446
428447 /// Create a new output file with given bytes.
0 commit comments