Understanding the safe-cli Rust code

Preferably not to be answered by Maidsafe Devs, but a community member who knows a bit of Rust (so as not to distract as this is not a priority).

I’m looking around in the safe-cli library at what bits of API are exposed and what is to come, and trying to understand some of the underlying Rust code.

The code in safe-cli/safe_api_ffi/ffi/mod.rs creates a Safe object (interface?) to auth the app, here:

That interface is implemented in safe-cli/src/api/auth.rs below.

I’d like to understand what the Safe::new("base32z"); above does, because I don’t see how new is implemented, and in particular what the “base32z” parameter does. Obviously it creates an instance that can be called, exposing the connect function, but I’m confused by the lack of a constructor (coming from a C++ / JavaScript background). Help?!


Hey there, on my phone so quick answer:

Seems to be this ctor:

I haven’t looked into it but seems like the argument to the ctor defines the format of the xorurls that will be handled by this instance.


Thanks @oetyng, so the implementation of the interface is spread around multiple files! I hadn’t realised that they were all being pulled together like that.

I think it would be clearer of the directory (api) and the interface (Safe) had the same name. cc @bochaco