buckyos / cyfs-ts-sdk

BSD 2-Clause "Simplified" License
8 stars 2 forks source link

How to develop CYFS dec_app using Rust? #15

Open justtwo2 opened 1 year ago

justtwo2 commented 1 year ago

General Question CYFS SDK cyfs-lib supports two programming languages, Rust and TypeScript. I want to develop a Dec app using Rust, how can I integrate it with app-manager? Is there any documentation for this?

lurenpluto commented 1 year ago

As a developer, when developing a DEC app, you generally don't need to interact directly with the app-manager. Instead, you use a descriptor file to tell the app-manager what to do during installation, such as executing installation scripts and commands, copying and deploying files, and requesting certain permissions.

Once the DEC app is installed and launched, there is usually no need to communicate directly with the app-manager. So, what specific requirement do you have for your DEC app that necessitates interaction with the app-manager?

The app-manager indeed has a set of commands designed to control the app's state, such as installation, uninstallation, starting, and stopping, based on post-object. However, these commands require system-level DEC permissions, and ordinary DEC apps cannot use them directly due to insufficient permission levels.

weiqiushi commented 1 year ago

Currently, cyfs-tool has partial support for DecApp developed by rust. Some necessary steps need to be done manually by developers. In future releases, we will try to gradually improve the development experience of Rust developers.

Note: The final support for rust projects by cyfs-tool is not yet finalized, and the description below only indicates the current support logic for rust by cyfs-tool, which is subject to change without notice

Unlike node developers, rust developers need to decide for themselves which platforms their DecApp supports, they need to:

  1. create the DecApp project in the normal way by calling the cyfs create command
  2. manually create {target} directory under {pack} directory. The name of the {target} directory matches the name of the target of rust, which means that the DecApp service supports this target.
  3. manually compile the binary service file of each target and put it in the directory of the corresponding target. 4.
  4. fill in these targets under service.dist_targets in cyfs.config.json of the project

After that, you can deploy the DecApp project in the same way as the node developer.

weiqiushi commented 1 year ago

Actually, this is more a question about cyfs-tool. AppManager does not care about the language in which the DecApp service is developed. You can even develop a DecApp in go, or python, as long as it conforms to the cyfs protocol specification.

I will move this Issue to the cyfs-ts-sdk repository