pnoltes opened a new pull request, #627:
URL: https://github.com/apache/celix/pull/627

   # Intro
   
   This PR completes the Rust feasibility issue (#599) by providing a proof of 
concept (PoC) implementation for Apache Celix with Rust.
   
   I invested more time in this than I had initially planned. However, as a 
result, this PoC IMO demonstrates nicely the feasibility of integrating Rust 
support into Apache Celix.
   
   It's good to highlight that this implementation serves as a proof of concept 
and is not ready for production. The code lacks consistent error checks, 
documentation, unit tests, and is not feature-complete.
   
   # Changes
   
   In this PR, the following are introduced:
   
   - A `celix` crate, which builds upon the `celix_bindings` crate, offering a 
Rust-native API for:
     - `Erno` enum module
     - `BundleActivator` module
     - `LogHelper` module
     - `BundleContext` module
   - The `BundleContext` module provides the following features:
     - Logging functions
     - Service registration builder
     - Service use builder
     - Service tracker builder
   - `LogHelper` uses a service tracker to fetch an on-demand C `log_service`.
   - An updated Rust "hello world" bundle that utilizes the BundleActivator
   - A Rust Shell API crate that:
     - Introduces a `RustShellCommand` type.
   - A Rust Shell command bundle that:
     - Utilizes the `BundleActivator`
     - Supplies both a C shell command and a Rust shell command (Note: The Rust 
shell command serves merely as a demonstration and is not actively utilized)
     - Uses the `BundleContext::use_service` to access both the Rust and C 
shell commands
   
   The `rust_shell_cnt` Apache Celix container/executable can be used to 
try-out Rust integration. With the `query -v` command it should give a nice 
overview of provided and used service in Rust.
   
   # Interesting Observations
   
   Rust's templating system, especially its type inference capabilities, is 
quite powerful. However, working with templates and traits can be - based on my 
experience - complex. The is mainly because traits aren't complete types. As a 
result, template methods cannot seamlessly move a provided trait type from a 
Box (pointer) to a different container type, like Arc (atomic reference count 
(shared_ptr)). My assumption is that this constraint is because of potential 
slicing and memory allocation/deallocation challenges. But, I am still learning 
the ins and outs of Rust, so maybe more is possible. Consequently, for this 
PoC, I decided to make type containers (e.g., Box, Arc, Rc) part of the service 
type. As result, from a Rust perspective, one does not register a 
'RustShellCommand' service type but an `Arc<RustShellCommand>` service type.
   
   While integrating Rust support into Apache Celix is feasible, I'm uncertain 
whether it's appropriate to include it directly within the Apache Celix main 
git repository, especially when leveraging CMake Corrosion. Though this method 
functions, in my experience is does not really integrate well with an IDE.
   
   Lastly, Rust, would arguably be a better fit, if Apache Celix could support 
both Static Bundles and Shared Object Bundles, in addition to Zip Bundles (#94).
   


-- 
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: dev-unsubscr...@celix.apache.org

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

Reply via email to