martin-g commented on code in PR #397:
URL: https://github.com/apache/avro-rs/pull/397#discussion_r2692060867


##########
avro/src/bytes.rs:
##########
@@ -136,6 +164,29 @@ pub mod serde_avro_fixed {
     use super::{BytesType, SER_BYTES_TYPE};
     use serde::{Deserializer, Serializer};
 
+    use crate::{
+        Schema,
+        schema::{FixedSchema, Name, Names, Namespace},
+    };
+
+    /// Returns `Schema::Fixed(N)` named `serde_avro_fixed_{N}`
+    pub fn get_schema_in_ctxt<const N: usize>(
+        named_schemas: &mut Names,
+        enclosing_namespace: &Namespace,
+    ) -> Schema {
+        let name = Name::new(&format!("serde_avro_fixed_{N}"))
+            .expect("Name is valid")
+            .fully_qualified_name(enclosing_namespace);

Review Comment:
   👍🏻 
   We should do the same for Uuid/Duration too: 
`Name::new().expect().fully_qualified_name()`



##########
avro_derive/src/attributes/mod.rs:
##########
@@ -145,13 +146,55 @@ impl VariantOptions {
     }
 }
 
+/// How to get the schema for this field or variant.
+#[derive(Debug, PartialEq, Default)]
+pub enum With {
+    /// Use `<T as AvroSchemaComponent>::get_schema_in_ctxt`.
+    #[default]
+    Trait,
+    /// Use `module::get_schema_in_ctxt` where the module is defined by 
Serde's `with` attribute.
+    Serde(Path),
+    /// Call the function in this expression.
+    Expr(Expr),
+}
+
+impl With {
+    fn from_avro_and_serde(
+        avro: &avro::With,
+        serde: &Option<String>,
+        span: Span,
+    ) -> Result<Self, syn::Error> {
+        match &avro {
+            avro::With::Trait => Ok(Self::Trait),
+            avro::With::Serde => {
+                if let Some(serde) = serde {
+                    let path = Path::from_string(serde).map_err(|err| {
+                        syn::Error::new(
+                            span,
+                            format!("Expected a path for `#[serde(with = 
\"..\")]: {err:?}"),

Review Comment:
   ```suggestion
                               format!("Expected a path for `#[serde(with = 
\"..\")]`: {err:?}"),
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to