Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lenra-io/app-lib-rust
Lenra's app lib for Rust apps
https://github.com/lenra-io/app-lib-rust
app-lib hacktoberfest lenra rust rust-lang
Last synced: about 2 months ago
JSON representation
Lenra's app lib for Rust apps
- Host: GitHub
- URL: https://github.com/lenra-io/app-lib-rust
- Owner: lenra-io
- License: mit
- Created: 2023-04-19T16:00:49.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-02-05T08:24:29.000Z (11 months ago)
- Last Synced: 2024-11-14T02:50:43.170Z (about 2 months ago)
- Topics: app-lib, hacktoberfest, lenra, rust, rust-lang
- Language: Rust
- Homepage:
- Size: 20.5 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Contributors][contributors-shield]][contributors-url]
[![Forks][forks-shield]][forks-url]
[![Stargazers][stars-shield]][stars-url]
[![Issues][issues-shield]][issues-url]
[![MIT License][license-shield]][license-url]
App Lib for Rust based Lenra projects
This lib integrates all the elements the app needs in order to only keep the views, listeners and resources in the app project.
[Report Bug](https://github.com/lenra-io/app-lib-rust/issues)
·
[Request Feature](https://github.com/lenra-io/app-lib-rust/issues)## Usage
To add it to your Lenra app project:
```console
cargo add lenra-app@~1.0.0-beta.0
```### Lenra API calls
To call the Lenra API from a listener, just use the Api instance in the parameter of your listener function.
You can then call the data API like that to create a document:
```rust
#[derive(Serialize, Deserialize, Debug, PartialEq, Default, Clone)]
pub struct CustomType {
#[serde(rename = "_id")]
pub id: Option,
pub value: String,
}impl Doc for CustomType {
fn id(&self) -> Option {
match &self.id {
Some(x) => Some(x.clone()),
None => None,
}
}
}#[derive(Serialize, Deserialize, Debug, PartialEq, Default)]
pub struct CustomProps {
value: String,
}
// Use the props! macro to generate the props struct automatically
props!(CustomProps);fn my_listener(params: ListenerParams) -> Result<()> {
let my_doc: CustomType = params.api.data.create_doc(
COUNTER_COLLECTION,
CustomProps {
value: CustomProps.value,
..Default::default()
},
)?;
Ok(())
}
```## Contributing
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.
If you have a suggestion that would make this better, please open an issue with the tag "enhancement" or "bug".
Don't forget to give the project a star! Thanks again!## License
Distributed under the **MIT** License. See [LICENSE](./LICENSE) for more information.
## Contact
Lenra - [@lenra_dev](https://twitter.com/lenra_dev) - [email protected]
Project Link: [https://github.com/lenra-io/app-lib-rust](https://github.com/lenra-io/app-lib-rust)
[contributors-shield]: https://img.shields.io/github/contributors/lenra-io/app-lib-rust.svg?style=for-the-badge
[contributors-url]: https://github.com/lenra-io/app-lib-rust/graphs/contributors
[forks-shield]: https://img.shields.io/github/forks/lenra-io/app-lib-rust.svg?style=for-the-badge
[forks-url]: https://github.com/lenra-io/app-lib-rust/network/members
[stars-shield]: https://img.shields.io/github/stars/lenra-io/app-lib-rust.svg?style=for-the-badge
[stars-url]: https://github.com/lenra-io/app-lib-rust/stargazers
[issues-shield]: https://img.shields.io/github/issues/lenra-io/app-lib-rust.svg?style=for-the-badge
[issues-url]: https://github.com/lenra-io/app-lib-rust/issues
[license-shield]: https://img.shields.io/github/license/lenra-io/app-lib-rust.svg?style=for-the-badge
[license-url]: https://github.com/lenra-io/app-lib-rust/blob/master/LICENSE.txt