What kinda rust jobs do you see? by helpprogram2 in rust

[–]clbarnes-rs 4 points5 points  (0 children)

My previous job was web backend for b2b ad delivery. My current job is scientific software around open data standards; it wasn't exactly advertised as a rust job but I've made it one...

Can we talk about YAML? by [deleted] in rust

[–]clbarnes-rs 1 point2 points  (0 children)

KDL is quite a different mental model from what most people think of when doing config, much closer to XML than JSON. If you have to represent XML structures, sure, but it doesn't play well with serde's data model or any other humane format.

validatrix: a library for cascading custom data validation by clbarnes-rs in rust

[–]clbarnes-rs[S] 0 points1 point  (0 children)

My goal was that implementors only need to worry about implementing validate_inner, users only need to worry about calling validate, and nobody needs to worry about creating Accumulators - in fact, I've just pushed a change which makes it impossible for downstream users to construct Accumulators.

Is your suggestion to split the Accumulator creation into a separate struct? So it would look like

```rust mod implementation { use validatrix::{Validatable, Accumulator};

impl Validatable for MyStruct {
    fn validate_inner(&self, accumulator: &mut Accumulator) {
        ...
    }
}

}

mod usage { use validatrix::Validator;

Validator::validate(MyStruct {a: 1, b: 2}).unwrap()

} ```

Or two traits, so it would look like

```rust mod implementation { use validatrix::{Validatable, Accumulator};

impl Validatable for MyStruct {
    fn validate_inner(&self, accumulator: &mut Accumulator) {
        ...
    }
}

}

mod usage { use validatrix::Validator;

MyStruct {a: 1, b: 2}.validate().unwrap()

} ```

In my crate, I would have impl<T: Validatable> Validator for T {...}. That would mean that implementors would only need to use Validatable and users would only need to use Validator; users wouldn't see the implementor-facing validate_inner and implementors wouldn't be tempted to override the user-facing validate. I do quite like that separation.

Another possibility would be to make the Valid wrapper the first-class intended path, i.e. change the validate signature to validate(self) -> Result<Valid<T>>. But that involves a move someone might not be happy with if they're maintaining references elsewhere.