tustvold commented on issue #172:
URL: https://github.com/apache/iceberg-rust/issues/172#issuecomment-2473277943

   > while making FileIO trait quite limited due to object safe in rust
   
   The transformation from the current abstraction to an object safe version 
_could_ be done largely mechanically
   
   ```
   #[derive(Debug, Clone, PartialEq, Eq)]
   pub struct FileIOProps(HashMap<String, String>);
   
   impl FileIOProps {
       pub fn with_prop() {...}
   
       pub fn iter(&self) -> impl Iterator<Item=(&str, &str)> {
           self.0.iter()
       }
   }
   
   pub trait FileIOBuilder {
       fn get(&self, scheme: &str, props: &FileIOProps) -> Result<Arc<dyn 
FileIO>>
   }
   
   #[async_trait]
   pub trait FileIO {
       async fn is_exist(&self, path: &str) -> Result<bool>;
   
       async fn new_input(&self, path: &str) -> Result<Box<dyn InputFile>>;
   
       ...
   }
   
   #[async_trait]
   pub trait InputFile {
       async fn metadata() -> Result<FileMetadata>;
   
       fn reader(&self) -> Result<Arc<dyn FileRead>>;
   }
   
   #[async_trait]
   pub trait InputFile {
       async fn metadata() -> Result<FileMetadata>;
   
       fn reader(&self) -> Result<Box<dyn FileRead>>;
   
       ...
   }
   
   #[async_trait]
   pub trait OutputFile {
       async fn metadata() -> Result<FileMetadata>;
   
       fn writer(&self) -> Result<Box<dyn FileWrite>>;
   
       ...
   }
   ```
   
   This would of course be more disruptive than what @alamb proposes, but would 
be more extensible and avoid needing to define a secondary extension interface.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to