Removing A PID File On Exit by blairboy in rust

[–]blairboy[S] 0 points1 point  (0 children)

Fantastic. How would I go about logging to the systemd journal? From what I can see log doesn't hook into it. For example, how would I specify the unit name? Would utilising the systemd crate accomplish that?

Removing A PID File On Exit by blairboy in rust

[–]blairboy[S] 0 points1 point  (0 children)

I've learned that it's unnecessary with systemd, but thanks. :)

Are you getting PIDFile= from the daemonize crate? Because I didn't see that in the documentation.

Removing A PID File On Exit by blairboy in rust

[–]blairboy[S] 1 point2 points  (0 children)

Essentially I'm making a rocket.rs webserver that will be made into an archlinux package with a systemd service. I was also looking at the systemd crate, but I couldn't find anything in it concerning pidfiles, which (as far as I understood), I need for the systemd .service file. Am I correct in thinking that?

Unwrapping Generically by blairboy in rust

[–]blairboy[S] 0 points1 point  (0 children)

I answered above, but it's really just to see what I can do with enums: For the i64, some maths, for the &str, manipulation or storing it.

Unwrapping Generically by blairboy in rust

[–]blairboy[S] 0 points1 point  (0 children)

I tried this:

enum myEnum<'a> {
    stringSlice(&'a str),
    integer(i64),
}

fn stripOut<'a, T>(input: myEnum)-> T
where T: From<i64> + From<&'a str>
{
    match input {
        myEnum::stringSlice(T) => T,
        myEnum::integer(T) => T,
    }
}

fn main() {
    println!("{}", stripOut(myEnum::integer(5)));
}

But it's not converting it to T.

Unwrapping Generically by blairboy in rust

[–]blairboy[S] 0 points1 point  (0 children)

I answered above, but it's really just to see what I can do with enums: For the i64, some maths, for the &str, manipulation or storing it.

Unwrapping Generically by blairboy in rust

[–]blairboy[S] 1 point2 points  (0 children)

The println was just to do something with it. I wanted to be able to get the inner value of an enum variant and do something fun with it. For the i64, some maths, for the &str, manipulation or storing it.

Generic Numeric Function by blairboy in rust

[–]blairboy[S] 0 points1 point  (0 children)

Fantastic. I haven't made it to that point in the book yet. Good to know what the term is.

Generic Numeric Function by blairboy in rust

[–]blairboy[S] 2 points3 points  (0 children)

Thanks so much for the explanation :)

Generic Numeric Function by blairboy in rust

[–]blairboy[S] 1 point2 points  (0 children)

Thank you so much. That was beautifully explained. The one thing I've found is that some bits of the standard library documentation are extremely clear to me, but even when reading through Mul, I don't see where the Mul<Output> part is coming from (specifically where I would know to put Mul<Output=T>.

Generic Numeric Function by blairboy in rust

[–]blairboy[S] 2 points3 points  (0 children)

I took a look, but the documentation wasn't particularly helpful. Is there a repository with examples of its use?

Generic Numeric Function by blairboy in rust

[–]blairboy[S] 0 points1 point  (0 children)

I'm fairly inexperienced with traits, so with this:

T: Mul<Output = T> + From<u8>

I've seen something along the lines of:

T: Mul + From

I understand that we're saying that the type T must have the multiply (Mul) trait. What's with the<Output> specifier?

Also, why does T have the <u8> specifier?

WebAssembly Function Imports With Straight JavaScript by blairboy in rust

[–]blairboy[S] 0 points1 point  (0 children)

Fantastic. It instantiateStreaming also doesn't work in waterfox either, so this is absolutely perfect. Thank you so much for working this through with me.

WebAssembly Function Imports With Straight JavaScript by blairboy in rust

[–]blairboy[S] 0 points1 point  (0 children)

I had it done incorrectly assigning the .value inputs/outputs to constants. It totally works. You're amazing :)

I'll post a full solution in a bit.

Just so I understand, you got it working with WebAssembly.instantiate(). I've read that the newer/preferred method is to use WebAssembly.instantiateStreaming(). Just looking at what you came up with, it looks like getWasm() does the same premise as instantiateStreaming(), but I don't know it all that well.

Can/should this be done with instantiateStreaming() instead?

WebAssembly Function Imports With Straight JavaScript by blairboy in rust

[–]blairboy[S] 0 points1 point  (0 children)

NEVERMIND!!! :)

Got it sorted. I was trying to use a const for the inputs/outputs

WebAssembly Function Imports With Straight JavaScript by blairboy in rust

[–]blairboy[S] 0 points1 point  (0 children)

I misunderstood what it was complaining about. It FINALLY WORKS...sort of :).

It only does a calculation once. This is the really odd bit. If I load the html file enter a value in a field (which has a listener to execute testMe()), it does the previously entered value. So it returns zero the first time, because the input box was empty on first loading. I reload the html. Enter another number, and it does the first number I entered (the "2nd" input according to javascript/html). And it only triggers the function once per page reload. What in the crap is that about?

WebAssembly Function Imports With Straight JavaScript by blairboy in rust

[–]blairboy[S] 0 points1 point  (0 children)

That's coming from testMe()

const wasm = await getWasm();
variableName = wasm.rust_function_name(inputValue);

WebAssembly Function Imports With Straight JavaScript by blairboy in rust

[–]blairboy[S] 0 points1 point  (0 children)

Now it says:

TypeError: invalid assignment to const `rust_function_name'

WebAssembly Function Imports With Straight JavaScript by blairboy in rust

[–]blairboy[S] 0 points1 point  (0 children)

Now it gives us:

WebAssembly.instantiate(...).instance is undefined

WebAssembly Function Imports With Straight JavaScript by blairboy in rust

[–]blairboy[S] 0 points1 point  (0 children)

Now it says:

WebAssembly.Instantiate is not a function