macro_rules! data_struct {
    (
		IMPL,
		$(#[$attr:meta])*
		($($vis:tt)*) $name:ident {
			$(
				$(#[$field_attr:meta])*
				$field:ident: $field_type:ty
			),*
		}
	) => { ... };
    ($(#[$attr:meta])* pub struct $($toks:tt)*) => { ... };
    ($(#[$attr:meta])* pub ($($vis:tt)+) struct $($toks:tt)*) => { ... };
    ($(#[$attr:meta])* struct $($toks:tt)*) => { ... };
}
Expand description

To access data from request handlers you need to create a data struct every request receivers a reference to this struct.

To access a value a method with the same name needs to be defined. This macro simplifies the creation of such methods.

Example

use fire::data_struct;
 
data_struct! {
	#[derive(Debug)]
	pub struct Data {
		/// Comment here
		field_1: String,
		another_field: usize
	}
}
 
let data = Data {
	field_1: "Field1".into(),
	another_field: 10
};
// automatically generates getter functions
let field_1 = data.field_1();
let another_field = data.another_field();
assert_eq!(field_1, "Field1");
assert_eq!(another_field, &10);