« first day (1725 days earlier)      last day (1756 days later) » 

5:38 AM
@Shepmaster FYI, I've updated my code to use a channel: gitlab.com/Boiethios/goa-rs/blob/channel/src/client/…
I'm not sure if it is legal to box a sender, use into_raw, and send it in a C callback. That may be a good SO question.
 
 
1 hour later…
6:45 AM
@Websterix 1:10 for you ... I know that feeling bro
 
Huh, I cannot find how to link my Rust lib with a linux shared object .so
There is a lot of ressources on how to create a so in Rust, but not the other way around
 
@FrenchBoiethios same as with a static one
6
Q: Linking Rust application with a dynamic library not in the runtime linker search path

AmeoI have a shared library that I'd like to dynamically link into several separate binary Cargo applications. I include its location in the linker using the -- -L /path/to/dir format and the application compiles correctly with the significant decrease in binary size I expect. However, when checkin...

1
Q: How to call a C++ dynamic library from Rust?

Chi Wei ShenI want to call a C++ dynamic library (*.so) from Rust, but I don't want to build it from Rust. Like this, cc::Build::new()     .file("src/foo.cc") .shared_flag(true) .compile("libfoo.so"); In some cases, I only need to call several functions, not all the functions. How can I use it?

or am I getting you wrong?
 
7:00 AM
Thanks
 
🥰 you're most welcome
 
I don't even know the difference between a so and a plugin :/
 
@FrenchBoiethios what is a plugin?
do you mean opening a .so at runtime?
 
Yes. That's strange that you can statically link a dynamic library…
But you can also load it at runtime
 
@FrenchBoiethios you mess something up. You don't statically link a dynamic lib, but instead you reference it, so that your ELF loader takes care of it loading the lib, throwing errors if it doesn't exist and resolving the .plt section for you
when you load it a runtime via dlopen you have to that all by yourself, but it's basically the same
 
7:14 AM
Oh ok. That's super cool, because I didn't want to do this job by hand.
That's much clearer. Thank you
 
@FrenchBoiethios stackoverflow.com/questions/5130654 here's a little info about that
 
8:01 AM
Ok, that works now :-))
 
🎉🥳🎉
 
That was dead simple: links = "goa-1.0" in the Cargo.toml and in the build.rs:
fn main() {
    println!("cargo:rustc-link-search=native=/usr/lib64/");
    println!("cargo:rustc-link-lib=dylib=goa-1.0");
}
 
println!("cargo:rustc-link-search=native=/usr/lib64/"); is that necessary? Doesn't rust do that automatically?
and when you lib is called libgoa.1.0 it should be found automatically
 
@hellow Was not a profitable day :D Anyways going for holiday nothing can upset me now :D
 
@Websterix wow :) enjoy your time!
 
8:19 AM
@hellow Really? I'll try that
For now, I've another issue: I'm having a deadlock (silly asynchronous C code)
 
@FrenchBoiethios x) why do you think every so in /usr/lib starts with lib... ^^
 
8:38 AM
I've tried the nightly async/await, and I was surprised that it's not possible to have an async main
 
@FrenchBoiethios if you are using tokio, you can write
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> { }
 
Ah, nice! I'll try that
 
 
2 hours later…
10:35 AM
Another package injection in npm: blog.npmjs.org/post/185397814280/…
At least they have a team to try fight this. We're even less protected
 
11:12 AM
BTW I'm OK to spend some time to validate some of your own small, marcro-free, useful crates if you give me their names.
 
11:26 AM
@DenysSéguret "macro-free"? x) why?
 
@hellow because as a half-noob I don't feel like I'm ready to check your macros...
So... what's your most interesting small crate that I could try to validate into crev?
 
@E_net4isaDownvoter uwu
 
11:43 AM
@DenysSéguret Hum, I'm building a binding of libgoa, it will likely be small (some thousands of lines) but full of asynchronous unsafe code :)
 
@FrenchBoiethios Then pingme when it's published (crev validation is per version)
 
12:02 PM
When you use a C lib, where do you put your extern funcs: all in one module (like c_defn), or each func in the module where it is used? And why?
 
@FrenchBoiethios I used to have a crate::ffi mod where I put the externs
 
Why?
BTW, ffi is a nice name for this module ;)
 
@набиячлэвэли I know. Please assume I'm busy
 
@E_net4isaDownvoter ЦшЦ
 
@FrenchBoiethios because why not. Typically I use bindgen to create the bindings for me and I have to include them somewhere so I choose ffi :)
@набиячлэвэли github.com/nabijaczleweli/safe-transmute-rs/pull/… what do you exactly want to achieve here?
 
12:09 PM
@hellow you're assuming that wasn't the third thing I tried
I did
it doesn't work, since it requires the user to do extern crate alloc
 
@набиячлэвэли well, that's how it should work ^^
 
Did someone already implement a future by hand?
 
My future implementation hangs when I put it in the tokio block_on
 
@FrenchBoiethios I also search for a simple example :| not sure how to use the context and waker and stuff without spawning a thread
@набиячлэвэли what
x(
 
12:10 PM
@FrenchBoiethios any sample code ?
 
when you have a macro and want to use types are defined in std you typically write ::std::result::Result
 
@hellow please explain to me how requiring the user to bring in seemingly random extern crate decls is a good thing
 
The SYNC version is ok, but we don't want a future to be sync, don't we? The async version is called once and hangs
 
@набиячлэвэли aaaah, isn't alloc in scope by default? :|
 
12:12 PM
@hellow almost as if most Rust code has an implicit extern crate std decl
@hellow no, for obvious compatibility et al. reasons
 
macro_rules! foo {
    () => {{
        extern crate alloc;
        alloc::vec::Vec::<u32>::new()
    }}
}
@набиячлэвэли ^
works
but it's not really nice ^^
 
@FrenchBoiethios is this a proper polling implementation ?
 
@ÖmerErden proper?
 
@hellow no it doesn't
 
using recv inside a poll
 
12:16 PM
@набиячлэвэли play.rust-lang.org/…
 
blocking it
 
honey please
 
---- src\util.rs - try_copy_unchecked (line 59) stdout ----
error[E0433]: failed to resolve: unresolved import
  --> src\util.rs:68:17
   |
10 |     let words = try_copy_unchecked!(transmute_many::<u16, SingleManyGuard>(bytes));
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |                 |
   |                 unresolved import
   |                 help: a similar path exists: `safe_transmute::alloc`
   |
   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more 
 
look at my mcve, it works ;) Now you just have to adjust your code
 
also, you're assuming I haven't tried this, again
 
12:17 PM
@ÖmerErden When I use the blocking recv, that's ok. But my async commented poll is not ok
When I see this question, it seems that it is much more difficult to do: stackoverflow.com/questions/52290738/…
 
@набиячлэвэли I've showed you that it works, now you have to show me your example that doesn't work
 
@hellow No, you have to prove it works in the case specified in the PR
 
@набиячлэвэли no, that's your work ;)
 
@FrenchBoiethios because in sync version poll is executed for once but in second you need to call polling for multiple times.
 
love a healthy dose of hypocrisy in the morning
 
12:20 PM
@ÖmerErden The block_on implementations of futures and tokio call poll only once.
 
@набиячлэвэли listen, you said you can't use alloc in a macro, I showed you that you can use extern crate alloc and afterwards it works. Then you said, it doesn't work in your example. I haven't even seen the code nor I have the time to look into it. Isolate the code, make a [mcve] and show it to me
 
SO MANY STUPID QUESTION
 
Capslock
 
@Stargateur The crate version one isn't really stupid, is it?
 
@DenysSéguret no just duplicate
 
12:23 PM
@hellow Don't stuff your words into my proverbial mouth. I didn't say anything, you picked up a comment meant for Enet from my PR to him and set out to prove me wrong and somehow decided that it's your life mission to "prove me wrong", despite me not claiming anything you say I did
 
you say it doesn't work. The comment on github is public, I thought it works, that's why I posted ::alloc::..., you said it doesn't, I saw that, yes it doesn't work that way. Then I opened up the playground and tested some things, found a solution, sent it to you
 
@hellow it's not a solution to the problem presented
QED
 
why not
 
because it doesn't solve the problem specified within the presented problem framework
 
@FrenchBoiethios some one needs to notify the task
otherwise it will not be polled again
 
@ÖmerErden Ahah! I'll try this, thanks
 
this example might help, i don't know it is a good implementation or not
 
@ÖmerErden Oh, that's an implementation of the futures' Future. The std Future is not like that. I'll see if this example can be used, tho
 
@FrenchBoiethios upss were you using std, sorry ^^ , but i believe both implementation has similarities
 
Yes, wake should do the job
 
12:32 PM
@FrenchBoiethios great, could you share if it works ? I was planning to dive into std futures
 
Unfortunately, I cant right now...
 
just the result ^^
 
@ÖmerErden That was that!! See the new version: gitlab.com/Boiethios/goa-rs/blob/channel/src/client/…
Thanks for your help, mate
I put a sleep to not wake the waker too much
 
12:50 PM
@FrenchBoiethios great!, thanks for sharing also, i don't know std futures but thread::sleep causes a problem in futures-rs please check (with see also section)stackoverflow.com/questions/56846492/…
 
yes
that's why this one spawns thread in here github.com/simmons/tokio-aio-examples/blob/…
 
@ÖmerErden any idea how to do it without spawning threads? :/ e.g. in a no_std environment
 
I'm not sure that the answer applies to my case. The OP wants to implement a timeout (like 1 or 2 seconds) with a sleep. In my case, I sleep briefly to not call wake too much. That's the same logic in a game's loop, when you sleep a few miliseconds to not saturate the CPU
@ÖmerErden But your example is very cool. There is an overhead to spawn a thread like that, tho
 
@hellow probably there is a best practice but i don't know, i am wishing to learn btw just couldn't find a proper document but i would create a watcher thread and send the task reference with a channel
 
12:58 PM
Eh, that's an idea
 
then would wake the task from that watcher thread
 
I'll try your idea this evening
But I think that won't work because the waker is borrowed from the context in the std Future
So you can send it, and return from poll
 
@FrenchBoiethios the waker is always Clone + Send + Sync doc.rust-lang.org/std/task/struct.Waker.html
 
Hum, nice. There's definitelly a thing to do. The thread can spawn a loop that have a list of (Waker, Duration), and when the duration is elapsed, the waker calls wake, and the pair is discarded. The loop also see if the receiver has another pair, and it adds it to the list.
Not sure if it is clear.
Something like that in pseudo-code:
spawn(move || {
    let mut wakers = vec![];
    loop {
        match receiver.try_recv() {
            Ok(pair) => wakers.push(pair),
            Err(Disconnected) => break,
            _ => (),
        }
        sleep(Duration::from_millis(10));
        for (waker, duration) in &mut wakers {
            *duration -= 10;
        }
        let mut i = 0;
        while i != vec.len() {
            if vec[i].duration == 0 {
                let (waker, _) = vec.remove(i);
                waker.wake();
 
1:23 PM
@FrenchBoiethios where do you use block_on from ?
is there any executor with thread pool ?
 
There is a receiver in the code. In your future, you have the corresponding sender, and you can ask to be awaken after X millisecond
You don't need an executor with this. The user can chose the one he wants
 
 
1 hour later…
2:47 PM
Hail Shep. :)
 
oh no, what I do this time
 
Nothing! I was just greeting you. :)
I gave my Ferris plushy a hat.
 
@E_net4isaDownvoter where did you get that from?
 
The Ferris, I suppose? From edunham's Kickstarter.
The hat was from a wedding invitation.
 
@E_net4isaDownvoter ohai
 
2:57 PM
@PeterVaro Yep, it seems you can buy it on devswag now. devswag.com/products/rust-ferris
All right, time to get going.
 
I'm not into plush toys tbh.. I wish there was a plastic action figure or something!
 
3:36 PM
fn path(p: &'static str), API is not letting you to pass &str with non-static lifetime. I've opened PR for this but this restriction might be added intentionally to create endpoints statically. — Ömer Erden 4 hours ago
@ÖmerErden ^ did you try using this in an actual full app? I bet it breaks trivially because of threads.
 
Filter trait doesn't even have send and sync
 
Doesn't need to.
the bounds are when you try to use the filter
 
these bounds tell T should be owned or cannot be borrowed unless it is static
 
@ÖmerErden All I'm saying is that you should add a test to prove that adding that lifetime allows what you claim it allows
 
I've tested it with the examples btw
 
3:50 PM
@ÖmerErden which examples?
 
@ÖmerErden all of the existing examples use 'static, so you haven't tested anything new.
 
@Shepmaster I haven't tested the issue that you said about threads, but on that case i expected a compiler error
i couldn't test it well, i admit it because of the network of my company
 
But i still think rust would give me a compiler error in this case
because there is nothing here to trick compiler
 
3:58 PM
@ÖmerErden Why would it give you an error? Every type lines up
Until you go to use a non-static reference.
 
in 2 different case i could get compile error
1- path would run some inner operations in another thread(or in some future operation)
2- usage of the returned impl Filter from a path(&input) might be in another thread which input doesn't live
we can simply ignore the first one because the implementation of path not works like that
for second one at the end path returns a struct FilterFn which implements copy trait
am i wrong it will copy itself while moving into a thread or other closure?
 
 
1 hour later…
5:23 PM
@Shepmaster The docs on snafu are not very local friendly at the moment. What is your take on this?
 
5:50 PM
@E_net4isaDownvoter you should make your comment an answer. It's useful even if you think it's trivial
 
@DenysSéguret Not until I'm sure that there isn't a good dupe target.
 
You can answer then let magicalshepbot autoclose :p
 
@E_net4isaDownvoter which kind of unfriendly? It relies on nightly for the intra doc links. It relies on rust 1.3x for the guide.
 
The code of cargo crev is uglier than what I'm used to. And I'm used to my code.
 
@Shepmaster If I cargo doc --open into the documentation, the links don't work.
 
5:57 PM
@E_net4isaDownvoter in stable, yes?
 
@Shepmaster ...Yes.
 
@E_net4isaDownvoter I don’t know how people are supposed to use nightly doc features
Like if you cargo +nightly doc it’s fine.
 
@Shepmaster I see. Nightly is magic.
 
@E_net4isaDownvoter so. What do? Could rewrite every link to be the terrible manual form
Add a piece to the docs that suggests viewing them with nightly?
 
At this point I don't know. :s Knowing that the documentation only works well on nightly helps.
 
 
1 hour later…
7:18 PM
A pretty cargo maze
(it's not really my code, I'm trying to refactor cargo crev)
 
 
3 hours later…
10:32 PM
@Shepmaster closed the PR, it was possible to solve the issue by cloning but i don't think the crate really need this.
Btw your example does not include the changes in my PR, error messages are totally different
 
11:06 PM
@ÖmerErden It certainly does:
$ git log HEAD~..
commit 6fd0dca24f7c9a281eda438e0488219c692bbaee (HEAD -> pr/251)
Author: Ömer Erden <omer.erden@siemens.com>
Date:   Fri Jul 5 14:00:52 2019 +0300

    Update path.rs

    Removed 'static lifetime restriction from the parameter of path function, now it accepts &str with an arbitrary lifetime.
$ git diff
diff --git a/examples/hello.rs b/examples/hello.rs
index fbbe6e3..480293c 100644
--- a/examples/hello.rs
+++ b/examples/hello.rs
@@ -1,11 +1,9 @@
-#![deny(warnings)]
 extern crate warp;

 use warp::Filter;

 fn main() {
-    // Match any request and return hello world!
-    let routes = warp::any().map(|| "Hello, World!");
+    let hello = warp::path(&String::from("tmp")).map(|| "hello world");

-    warp::serve(routes).run(([127, 0, 0, 1], 3030));
+    warp::serve(hello).run(([127, 0, 0, 1], 8080));
 

« first day (1725 days earlier)      last day (1756 days later) »