rust-nostr / hello-nostr

https://rust-nostr.org
14 stars 4 forks source link

error in code once i add #better filtering via tutorial #5

Closed hdlslm closed 1 year ago

hdlslm commented 1 year ago

my code compiles just fine following the tutorial except when i get to #better filtering i receive the following compile errors:

error[E0308]: mismatched types --> src/main.rs:30:28 30 authors: Some(vec![my_keys.public_key()]), ^^^^^^^^^^^^^^^^^^^^- help: try using a conversion method: .to_string()
expected String, found XOnlyPublicKey

error[E0063]: missing fields custom and identifiers in initializer of nostr_sdk::Filter --> src/main.rs:28:18 | 28 | let filter = Filter { | ^^^^^^ missing custom and identifiers

hdlslm commented 1 year ago

ok i was able to "fix" error e0308 i removed .to_string from this line of code: let message = format!("Hola, nostr! My public key is: {}", my_keys.public_key()); and added it to .public_key method in the authors:Some....line of code now i'm just getting the one error messeage: error[E0063]: missing fields custom and identifiers in initializer of nostr_sdk::Filter --> src/main.rs:28:22 | 28 | let filter = Filter { | ^^^^^^ missing custom and identifiers

hdlslm commented 1 year ago

adding identifiers: None, got rid of the identifiers portion of the error now i need to do something for the custom initializer bc it doesn't expect the same params. i'm thinking Some(HashMap::new()) or something still working on it lol

hdlslm commented 1 year ago

custom: Default::default(), ended up working so the entire line of code if anyone is interested is:

    let filter = Filter {
    ids: None,
    authors: Some(vec![my_keys.public_key().to_string()]),
    kinds: None,
    events: None,
    pubkeys: None,
    hashtags: None,
    references: None,
    search: None,
    since: None,
    until: None,
    limit: None,
    identifiers: None,
    custom: Default::default(),
};