Consider making the Simple API private
Currently, almost all of the YDBRust API is duplicated between the Simple API and the Context API. That means that e.g. updating the documentation has to be done in two places, but also that it's more complicated from the end user perspective: should they use the Simple API or the Context API?
I don't think there's any case where the Simple API is more efficient other than letting you provide your own buffer. That could be addressed by adding Context::with_buffer
or something like that, but I'm not sure even that's necessary - Context::new
doesn't allocate and all the associated functions take care of reallocating if needed.
I do think the Simple API allows you to be more flexible with respect to multi-threading, since you can't pass a Context
between threads. I could make that flexible by adding Context::with_tptoken
, although that unlocks a whole can of worms with respect to transaction processing (since now you could pass in the tptoken for a transaction that's already ended). That could be ameliorated somewhat by tying the tptoken to the lifetime of the context, so you can't use it after exiting the transaction:
struct TpToken<'a>(u64, PhantomData<&'a u64>);
impl Context {
fn tptoken(&self) -> TpToken { /* .. */ }
}
I'm not sure if there's any scenario where you can use a tptoken after exiting the transaction it belongs to - if so, this wouldn't be as flexible as the current API.
Anyway, this is probably a crazy idea, but I thought I'd bring it up.