Setting Up
This quickstart provides step-by-step instructions on installing and setting up the Ditto SDK in your Rust project.
To integrate Ditto with your app:
- Create a new project and add the Ditto SDK as a project dependency. (Creating Project and Installing Ditto SDK)
- Set up the directory and file structure for your project. (Setting Up Project Layout)
- Configure your project for cross-compilation. (Configuring for Cross-Compilation)
Create a new Rust project that uses the Ditto SDK:
- Create your new Rust project by running cargo init --bin.
- From the Cargo.toml file in your project directory, add the Ditto SDK as a project dependency:
The Rust programming language does not enforce that you use a specific file structure on your app’s end-user device’s filesystem; you can organize your project layout however you prefer; however, Ditto recommends that you organize and structure your project layout as follows:
The AppRoot/AppExecutable path is the entry point of your app that contains your app’s main executable file. Structure everything else in your filesystem relative to the AppRoot/AppExecutable path.
By default, the binary component of Ditto (libdittoffi.dll) is statically linked into your app’s main executable file. For more information, see Dynamic Link Library: libdittooffi.dll, as follows.
The AppRoot/libdittoffi.dll path contains the binary component of Ditto. Ditto’s binary component is a pre-compiled shared library file, also known as the dynamic link library (DLL). This libdittoffi.dll file contains the actual code implementations that enable Ditto platform capabilities, such as data sync.
If you want to use Ditto’s dynamic link library, configure your app’s linker to search for the libdittoffi.dll file in this path at build. For example, if configuring the linker to reference the @executable_path, configure your app’s linker as: @executable_path/../libdittoffi.dylib.
When distributing your app to end users, if you are using the Ditto SDK’s shared library version, you must include the build output directory’s shared library file in your distributed app.
With Rust’s native support for cross-compilation, you can deploy your code on a wide range of environments and platforms. For instance, using the same Rust code, you can cross-compile to create native code that runs on iOS and Android platforms for mobile apps; WebAssembly (Wasm), Rust-in-the-browser deployment; as well as Linux and MacOS for desktop and server apps.