Synphonyte / leptos-struct-table

Easily create Leptos table components from structs
Apache License 2.0
154 stars 23 forks source link

Implement own value trait #28

Closed lukashermansson closed 4 months ago

lukashermansson commented 4 months ago

As per Rust rules it's not possible to implement a forigin trait on a forigin type, a common pattern to circumvent this is to introduce "newtypes" as we had previously on Uuid. This however has some issues, namely that some standard crates has had important implementations provided for those types making usage of those libraries clunky together with leptos-struct-table this pr could make atleast some of those cases avoidable.

This pr:

and we can, in this crate provide some nice default rendering for the types of well known crates (behind feature flags) as done here with the Uuid type (the actual one from the uuid crate). I think it would be nice to implement CellValue for some types from time along with other well known and well used crates in the ecosystem in upcomming pr-s

I have a feeling we could ditch a lot of the special handling built into the derive macro for chrono but not 100% sure about that yet.

I made a previous pr #26 that I agree is subpar. This aproach feels much better, atleast to me but I think it achives the same benefit in the end, that this library can be used together with sqlx::FromRow even in more complex cases

Any feedback welcome

maccesch commented 4 months ago

I like the idea a lot!

Value might be a bit generic. How do you like CellValue or RenderableValue?

maccesch commented 4 months ago

Very nice! Thanks!!