Follow these steps to be able to include legacy code in your project:
- Let's implement the Rust library first. Open rust-digest/Cargo.toml to adjust the configuration to output a dynamic library (*.so or *.dll):
[lib]name = "digest"crate-type = ["cdylib"]
- Another thing to add is the dependencies. Here, we are using types from libc and a cryptography library called ring, so let's add those dependencies:
[dependencies]libc = "0.2"ring = "0.14"
- Next, we can take care of the code itself. Let's open rust-digest/src/lib.rs and replace the default code with the following snippet. This snippet creates an interface from the outside world that accepts a string (a mutable character pointer) and returns a string digest of the input: ...