Safe_client_libs , which network?


#1

Hello !

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.

ty !


#2

ok, I was searching the source, but didn’t look into tagret/debug/examples

self_authenticator.crust.config was here waiting for me :slight_smile:

launching the examples create empty config files, then fail. You just need to fill in the files and launch the example again.

Then examples now work like a charm!


#3

Examples does work indeed. Thanks for the help.

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!


#4

Did you also have the #[macro_use] statement just before that extern crate line?


#5

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.


#6

Thanks for your input.

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]

#![allow(unused_extern_crates)]#[macro_use]
extern crate maidsafe_utilities;
extern crate time;
extern crate routing;
extern crate safe_core;
#[macro_use]
extern crate unwrap;
#[macro_use]
extern crate chan;

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.


#7

https://gitlab.com/Grizmoblust/safe_orbtk-rs/merge_requests/1 Hope that helps a bit.


#8

Wow! Thanks for the help!

I noticed you add [lib] and [bin]to the Cargo.toml, and what does this do exactly? Does it get lib.rs to recognize the sub folders?

You removed main.rs. Is it because it was conflicting with lib.rs?

Don’t I need main.rs, to get app running?

Thanks again!

Edited:

It seems that I should create main.rs inside of /bin/ ?


#9

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 :slight_smile:


#10

Thank you so much!

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.


#11

Not at all you are all good there chap :slight_smile:


#12