Derive Macro bagel::Stor

source · []
    // Attributes available to this derive:
Expand description

Stor: Get the setters derived

Stor takes the fields in order and generates setters for each field. For example, if you have fields named userid and name, then the setters generated will be set_userid and set_name, accepting values for the appropriate types. In other words, set_* named methods will be derived per your fields.


use bagel::Stor;
struct MyStruct {
    name: String,
    userid: u64,

let mut ms = MyStruct { name: "Sayan".to_owned(), userid: 1 };
assert_eq!(, "Sayan");
assert_eq!(ms.userid, 1);
assert_eq!(ms.userid, 0);


The following attributes are available:

  • #[phantom]: Skips the stor for the specified field(s), assuming they are PhantomData fields. This has the same effect as #[stor_skip] but it makes it easier to use with the other macros, avoiding the need to write skips for phantom fields specifically
  • #[stor_skip]: Skips the stor for the specified field(s)


The Stor macro will automatically add a doc comment of the form:

Sets the value for the `<struct_field>` field in struct [`<struct_name>`]