crepererum commented on issue #7135:
URL: https://github.com/apache/arrow-rs/issues/7135#issuecomment-2668602700

   I had a chat w/ @tustvold and I agree w/ him that adding a new method 
doesn't sound good. Adding an extension point to `GetOptions` & Co (potentially 
`PutOptions` as well) sounds better. We should document that the builtin stores 
will basically ignore them. Also note that `Any` might not be the best type to 
keep (see https://github.com/apache/arrow-rs/pull/7152#discussion_r1961141517), 
but maybe something like this:
   
   ```rust
   struct Extensions {
       inner: HashMap<TypeId, Box<dyn Extension>>,
   }
   
   impl Extensions {
       pub fn get::<T>(&self) -> Option<&T> where T: Extension {
           self.inner.get(TypeId::of::<T>()).map(|ext| {
               ext.as_any().downcast_ref().expect("correct type IDs are 
enforced by the compiler")
           })
       }
   
       pub fn set::<T>(&self, ext: T) -> Option<T> where T: Extension {
           self.inner.insert(TypeId::of::<T>(), Box::new(ext)).map(|ext| {
               ext.as_any().downcast_ref().expect("correct type IDs are 
enforced by the compiler")
           })
       }
   }
   
   impl PartialEq for Extensions {
       // ...
   }
   
   trait Extensions: PartialEq<Self> + std::fmt::Debug {
       fn as_any(&self) -> &dyn Any;
   }
   ```
   
   This is roughly modeled after 
[`datafusion::common::config::Extensions`](https://docs.rs/datafusion/latest/datafusion/common/config/struct.Extensions.html).


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to