fuel-streams-subject

Crates.iofuel-streams-subject
lib.rsfuel-streams-subject
version
sourcesrc
created_at2025-02-13 16:42:21.891098+00
updated_at2025-03-13 22:12:24.34087+00
descriptionMacros for implementing subject functionality in the fuel-streams crate
homepagehttps://fuel.network/
repositoryhttps://github.com/fuellabs/data-systems
max_upload_size
id1554466
Cargo.toml error:TOML parse error at line 19, column 1 | 19 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
(fuel-service-user)

documentation

README


Logo

Fuel Streams Subject

Macros for implementing subject functionality in the fuel-streams ecosystem

CI Coverage Crates.io MSRV crates.io docs

📚 Documentation   🐛 Report Bug   ✨ Request Feature

📝 About The Project

Provides macros for implementing subject functionality in the fuel-streams ecosystem.

[!NOTE] This crate is specifically modeled for the Fuel Data Systems project, and is not intended for general use outside of the project.

🚀 Usage

The Subject derive macro allows you to easily implement the Subject trait for your structs. It generates methods for parsing, building, and creating subjectsfor your subject.

Example:

use fuel_streams_subject::subject::*;

#[derive(Subject, Debug, Clone, Default, serde::Serialize, serde::Deserialize)]
#[subject(id = "test")]
#[subject(entity = "Test")]
#[subject(query_all = "test.>")]
#[subject(format = "test.{field1}.{field2}")]
struct TestSubject {
    field1: Option<String>,
    field2: Option<u32>,
}

// Create a new TestSubject
let subject = TestSubject {
    field1: Some("foo".to_string()),
    field2: Some(55),
};

// Parse the subject
assert_eq!(subject.parse(), "test.foo.55");

// Create a subject string
assert_eq!(TestSubject::build_string(None, Some(10)), "test.*.10");

// Create using the build method
let subject = TestSubject::build(Some("foo".into()), Some(55));
assert_eq!(subject.parse(), "test.foo.55");

// Create a new TestSubject with the builder pattern
let subject = TestSubject::new()
    .with_field1(Some("foo".to_string()))
    .with_field2(Some(55));
assert_eq!(subject.parse(), "test.foo.55");

// Convert to a string
assert_eq!(&subject.to_string(), "test.foo.55");

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

For more information on contributing, please see the CONTRIBUTING.md file in the root of the repository.

📜 License

This repo is licensed under the Apache-2.0 license. See LICENSE for more information.

Commit count: 288

cargo fmt