Follow

This week's type of the day is `Result<Option<Result<Bytes>>>`

· · Web · 4 · 5 · 11

@jonny Maybe, i just have different errors I need to send for each level. I'm wrapping a read from a channel of io results in a timeout.

@mauve i wanna see this, i am still fumbling around in the baby end of the rust swimming pool where im' not doing anything fancier than pure functions to wrap with pyO3

@mauve
Oh this is a very familiar pattern :). Dang I need to read more live rust instead of book rust because that just makes sense

@jonny I've mostly been reading the source code of @VeilidNetwork and @n0iroh and filling in my gaps on syntax as I go. The error messages in rustc have been pretty handy (except when they're not :P )

@mauve this is just a less efficient encoding of `Result<Bytes, E>` for some `E`

@jeremy_list In this case each layer has a different meaning it's basically Didn't Time Out ( Stream still Open ( IO read didn't fail (Bytes)))

@mauve I'd personally only handle it that way if some other crate I was using made it unusually difficult not to. Most of the time squashing it to one layer and pushing that completely into the error type instead ends up simplifying things overall.

@jeremy_list Good point I could probably wrap it in a macro to map the option and flatten it all.

@mauve this reminds of one of my data.items[0].data.items variable from a while ago :)

Sign in to participate in the conversation
Mauvestodon

Escape ship from centralized social media run by Mauve.