I am playing with safe_client_libs, trying to run the examples against real routing.
examples fail and panick at creating an account, but I suppose I should tell them someway that I want to connect , for instance, to test_12c ? Is it even possible to talk to 12c this way ? In the positive, how would you do that ? I am digging the sources, but I can’t find a place where to configure this.
I decided moved to another folder, “safe” so that I could call safe through an app I am building. However, the problem I can’t seem to understand, how do I properly write macro if the macro is defined in a module?
Basically what I done was put an example in src/safe/mod.rs. Inside src/main.rs file contains,
pub mod safe;
fn main() {
safe::start();
}
The error is…
error[E0468]: an `extern crate` loading macros must be at the crate root
--> src/safe/mod.rs:47:1
|
47 | extern crate maidsafe_utilities;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
From what I am understanding, is that all of the extern crate need to move to src/lib.rs.
If I move it to lib.rs file, while leaving the code intact in mod.rs, then I would get an error, missing macro!
Just so you know, the rust community is pretty active and helpful so you might get a quicker response for questions like this on rust. You might have already tried there though.
Yes. I did placed them in the crate root, before the extern crate line. Everything is the same exact copy from the example. All I did was cut, and moved the extern crate to src/lib.rs with #[macro_use]
If I did that, and remove the extern crate from mod.rs then the code becomes faulty, because it needs those extern crate to express the commands. To understand what I’m talking about, here’s the code..
Do note that there are three different commits, for three different errors…
Latest commit, I re-add the extern crate. Remove macro from crate section, and place it in the function. The error says it is missing macro. I did remove the (unwrap, chan) from `#[macro_use] for more test. Same problem.
Third latest commit states that it is missing extern crate. I added macro to each function, and the error still persistent.
Fourth latest commit states that extern crate must be saved in root.
I guess, I might made this complicated but I’m trying knit it all up together. I’ll do more testing later. Skip the “core” folder. I plan to conjunct both together, once I get safe folder set up properly.
Ah sorry I missed that file, I added now and did a PR to your repo.
Yes the cargo toml structure there allows a bin and lib to exist in the same repo. Otherwise it can get confusing a wee bit, so this is more like ou create teh lib and add in a binary that uses the lib. It keeps it simple I think.
I also renamed safe/lib.rs to safe/safe_lib No real reason but it could confuse the compiler, I Am not sure. Usually a mod has some files in that that are all named specifically (bot not same name as mod). Not sure I am too clear there, but hope you get it anyway form my ramblings
I didn’t realized it could confuse the compiler. I was throwing stuff together and see how it turns out. You know, like a baby trying fit a block into a circle. That kind of thing.
I hope I’m not making this app too complicated but I think it needs to be this way when I start adding a lot more features into it.