milenkovicm commented on issue #9529:
URL: 
https://github.com/apache/arrow-datafusion/issues/9529#issuecomment-1988451635

   ```rust
   // does not work
   //
   // the trait `ConfigExtension` cannot be made into an object
   // `ConfigExtension` cannot be made into an object
   // for a trait to be "object safe" it needs to allow building a vtable to 
   // allow the call to be resolvable dynamically; for more information visit
   //
   fn configuration(&self) -> Option<&dyn ConfigExtension> {
       todo!()
   }
   ```
   ```rust
   //
   // does work but I don't like it 
   // 
   // user can  return whatever they want, registration process 
   // should try to register extension ... 
   // this would involve creating documentation to 
   // explain what we want, which makes bad API IMHO 
   fn configuration(&self) -> Option<dyn Any> {
       None
   }
   ```
   ```rust
   // we can let user do it on init
   // user should know what they are doing 
   //
   // i dont find this api particullary useful at this point
   fn init(&self, state: &mut SessionState) {
       state.options().extensions.insert(extension)
   }
   ```
   ```rust
   /// config extension to register with this function factory 
   fn config_extension<T:ConfigExtension>() -> Option<T> where Self: Sized {
       None
   }
   ```
   ```rust
   pub fn with_function_factory(
       mut self,
       function_factory: Arc<dyn FunctionFactory>,
   ) -> Self {
       // the size for values of type `dyn FunctionFactory` cannot be known at 
compilation time
       // the trait `Sized` is not implemented for `dyn FunctionFactory
       let c = <dyn FunctionFactory>::config_extension();
   
       self.function_factory = Some(function_factory);
       self
   }
   ```
   ```rust
   // it would force user to define `ConfigExtension`
   pub fn with_function_factory<T: FunctionFactory + 'static, C : 
ConfigExtension>(
       mut self,
       function_factory: Arc<T>,
   ) -> Self {
       let c : Option<C> = T::config_extension();
       self.function_factory = Some(function_factory);
       
       self
   }
   ```


-- 
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