Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Johann Tuffe
    @tafia
    You should use read_exact and then convert it to a String
    Daniel Collin
    @emoon
    Yeah, I guess I need to do it myself at least.
    Fletcher Haynes
    @fhaynes
    Hello! Is there a way to split a String on just the first occurrence of a delimiter?
    Lilian Anatolie Moraru
    @lilianmoraru
    Fletcher Haynes
    @fhaynes
    ahh, splitn is what I was looking for. Thank you, I somehow missed that in the docs
    loggerhead
    @loggerhead
    Hello. Is there anyone used rust-crypto to encrypt and decrypt stream data?
    Seems SynchronousStreamCipher is what I want, but there is only a method named "process" to do encrypt and I can't find the method which do decrypt
    Sergey Noskov
    @Albibek
    @loggerhead , are you sure you're about correct semantics here? It seems to me that this trait is more about stream ciphers(https://en.wikipedia.org/wiki/Stream_cipher), but not about encrypting stream data
    Anyways since stream ciphers are using xor, the decrypt operation is repeating of encrypt operation on encrypted data.
    loggerhead
    @loggerhead
    I have read the wiki, seems "SynchronousStreamCipher::process" is used to encrypt stream data. Otherwise, what's function it provide?
    Oh, thank you very much! I have been stuck at finding a way to decrypt stream data because of my ignorant of the working principle.
    Ironpillow
    @ironpillow
    hi all, I am working on a concurrent ping program (send ping to multiple hosts at the same time). I got the basic - send/receive icmp packets for now. I am trying to make this async using mioco lib. But being new to concurrent programming, I am stuck. https://gist.github.com/ironpillow/d64f644fc42a05c2bcb5e4a3dff84815
    Andréy Lesnikóv
    @ozkriff
    Andrey Ivanov
    @a-nigredo

    hi all, I'm using manual(https://doc.rust-lang.org/book) for studying rust but I'm stuck on https://doc.rust-lang.org/book/crates-and-modules.html#exporting-a-public-interface. It doesnt compile with message:

    
       Compiling phrases v0.1.0 (file:///D:/rust/phrases)
    src\main.rs:7:38: 7:54 error: unresolved name `greetings::hello` [E0425]
    src\main.rs:7     println!("Hello in English: {}", greetings::hello());
                                                       ^~~~~~~~~~~~~~~~
    <std macros>:2:27: 2:58 note: in this expansion of format_args!
    <std macros>:3:1: 3:54 note: in this expansion of print! (defined in <std macros>)
    src\main.rs:7:5: 7:58 note: in this expansion of println! (defined in <std macros>)
    src\main.rs:7:38: 7:54 help: run `rustc --explain E0425` to see a detailed explanation
    src\main.rs:8:40: 8:58 error: unresolved name `farewells::goodbye` [E0425]
    src\main.rs:8     println!("Goodbye in English: {}", farewells::goodbye());
                                                         ^~~~~~~~~~~~~~~~~~
    <std macros>:2:27: 2:58 note: in this expansion of format_args!
    <std macros>:3:1: 3:54 note: in this expansion of print! (defined in <std macros>)
    src\main.rs:8:5: 8:62 note: in this expansion of println! (defined in <std macros>)
    src\main.rs:8:40: 8:58 help: run `rustc --explain E0425` to see a detailed explanation
    error: aborting due to 2 previous errors
    error: Could not compile `phrases`.

    is it an error in manual or I'm doing something wrong?

    Lilian Anatolie Moraru
    @lilianmoraru
    You probably copied the text without the previous statements
    You can press on the website(go with the mouse over the code in the website) on the "Run" button. It will open up the playground with all the code that is needed to compile
    For demonstration purposes the code is cut in smaller pieces, so if you take a small piece, it won't compile by itself.
    If the modules are internal, than you are probably missing
    mod greetings;
    mod farewells;
    Andrey Ivanov
    @a-nigredo
    @lilianmoraru ok, ty, I'll try
    Lilian Anatolie Moraru
    @lilianmoraru
    Ok, I see the example is using a crate that you probably created before that(I have not re-read The Book for a long time and I think this example changed)
    No, to solve your problem you need to go through all the next steps the example mentiones
    And then compile
    If you are still blocked, put it on a pastebin or https://gist.github.com/
    Andrey Ivanov
    @a-nigredo
    ok
    Lilian Anatolie Moraru
    @lilianmoraru
    the code*
    Zakarum
    @omni-viral

    Why there is an error?

    trait X {
        fn into_trait(&self) -> &X { self }
    }

    Compiler says I have to add Self: Sized. What for?

    Sergey Noskov
    @Albibek
    You can only return values which size is known at compile time.
    Zakarum
    @omni-viral
    I return reference
    It always has known size
    Thomas Koehler
    @Bastacyclop
    probably because it doesn't know wether the reference is fat or not ?
    Andrii
    @j2ko
    struct X {}
    impl X {
        fn into_trait(&self) -> &X { self }
    }
    Zakarum
    @omni-viral
    @j2ko <thumb-up> But this is not what I need.
    @Albibek I understood.
    Also I can't declare trait X: Sized {...}. and make trait-objects &X
    I found one solution. I'll implement this function in trait implementations. Where I would know that Self: Sized. And I would use it for conversion.
    Zakarum
    @omni-viral
    @j2ko I need to get trait-object. Not &Self
    Thomas Koehler
    @Bastacyclop
    trait X {
        fn into_trait(&self) -> &X where Self: Sized { self }
    }
    is this not enough ?
    Zakarum
    @omni-viral
    I can't add Self: Sized. Because I want to call this function via trait-object.
    Thomas Koehler
    @Bastacyclop
    so you have a trait object Y (object pointer + virtual table for Y) and you want to get a trait object X (object pointer + virtual table for X) ?
    Zakarum
    @omni-viral
    Yeap.
    But X equals Y
    Thomas Koehler
    @Bastacyclop
    what's the point if they are equal ?
    Zakarum
    @omni-viral
    I have heterogeneous tree structure
    trait TreeNode {
        fn find(&'a self, some_stuff_to_find_right_node) -> Option<&'a TreeNode>
    }
    Here TreeNode contains other TreeNodes. Which can have different type
    Thomas Koehler
    @Bastacyclop
    trait TreeNode {
        fn find(&self) -> Option<&TreeNode>;
    }
    this compiles, so the problem is only in the implementation, I'm going out right now, good luck
    ^ @SCareAngel
    Johann Tuffe
    @tafia
    Either that or return a Box<.
    Box<TreeNode>