Hi Sonke,

Is there currently any plans to generically convert any Struct or Class type into Bson for insertion into MongoDB?

Something that would work like the following:

struct MyStruct{ int a; }
MyStruct myStruct = MyStruct(1);
Bson bson = Bson(myStruct); 

MyStruct theCopy = bson.get!MyStruct;
assert(myStruct == theCopy);

Ideally, I think thats a pretty nice usage scenario.

At first glance I dont think it would be a huge job to add to the framework.

A couple of templates to test whether a struct/class has the functions to convert to and from Bson, and an addition to the Type enum in the Bson module to accept custom objects, which would then go and call the relevant functions.
Of course, it would still be up to the programmer to provide the necessary functions to do the actual conversion.
I think it would make talking to the DB pretty nice and clean to use.

What do you think? Would it be useful?
If something like that isnt already there of course, you seem to have thought of everything else! :)