Skip to content

Conversation

@ma2bd
Copy link
Contributor

@ma2bd ma2bd commented Dec 9, 2025

Summary

Following suggestions from @jordens in #73, we make a number of APIs and types pub.

Test Plan

CI

Copy link

@jordens jordens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.
While this would work for me, I rejected the same approach in my PR because it (1) leaves the door open for an inconsistent registry (missing variants) and (2) misses the opportunity to detect an infinite loop due to logic errors that the other approach could detect. The latter is merely a side effect as there is no known case of such an infinite loop AFAICT. The first one is the original argument. See below for a unittest showing this problem.

Ok((format, value))
}

/// Read the status of an enum and reset the value.
Copy link

@jordens jordens Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this you can do this (the reduced test from #73):

#[test]
fn test_pending_enum() {
    #[derive(Deserialize)]
    enum E {
        A,
        B,
    }


    let mut tracer = Tracer::new(TracerConfig::default());
    let samples = Samples::new();
    let mut format = Format::unknown();
    let deserializer = Deserializer::new(&mut tracer, &samples, &mut format);
    E::deserialize(deserializer).unwrap();
    format.reduce();
    let Format::TypeName(name) = &format else {
        panic!()
    };
    assert!(tracer.check_incomplete_enum(name).is_some());
    assert_eq!(
        tracer.registry(),
        Err(Error::MissingVariants(vec!["E".to_owned()]))
    );
}

which results in:

---- test_pending_enum stdout ----
thread 'test_pending_enum' panicked at serde-reflection/tests/serde.rs:527:5:
assertion `left == right` failed
  left: Ok({"E": Enum({4294967294: Named { name: "A", value: Unit }})})
 right: Err(MissingVariants(["E"]))

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

@ma2bd ma2bd Dec 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's start with this PR and see if we need anything more later.

@ma2bd ma2bd merged commit b19be2c into zefchain:main Dec 14, 2025
2 checks passed
@ma2bd ma2bd deleted the external_tracing branch December 14, 2025 22:16
jordens added a commit to quartiq/serde-reflection that referenced this pull request Dec 15, 2025
* upstream/main:
  Allow external tracing procedures (zefchain#85)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants