Uploaded image for project: 'Apache Avro'
  1. Apache Avro
  2. AVRO-3633

Additional attributes for 'avro_derive' crate

    XMLWordPrintableJSON

Details

    Description

      Hello,

      At the moment it is not possible to skip or rename a specific field within a struct derived with 'AvroSchema'. For e.g.

      use std::time::Instant;
      
      use apache_avro::AvroSchema;
      use serde::Deserialize;
      use serde::Serialize;
      
      #[derive(Clone, Debug, Deserialize, Serialize, AvroSchema)]
      pub struct FileDescriptor {
          #[avro(rename = "pflags")]    // <--- NOT POSSIBLE
          #[serde(rename = "pflags")]
          pub flags: u64,
          #[avro(skip)]                 // <--- NOT POSSIBLE
          #[serde(skip)]
          access_time: Instant,
      }

      I would like to suggest to implement additional attributes 'skip' and 'rename' to the 'avro_derive' crate. These attributes are also common in other procedural macro crates like 'serde'.

      Exemplary proposal:

      https://www.diffchecker.com/iju3tSuX

       

      Best Regards,

      Jimmy

      Attachments

        Issue Links

          Activity

            People

              mgrigorov Martin Tzvetanov Grigorov
              jpram Jimmy Pramosi
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - 1h
                  1h
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h
                  1h