card_id: usize is not enough #3

Open
opened 2024-11-04 10:23:27 +00:00 by Madoshakalaka · 2 comments
Madoshakalaka commented 2024-11-04 10:23:27 +00:00 (Migrated from gitlab.com)

I have been getting errors when I use guiCurrentCard and other note/card related APIs, it turns out my note id are outside of the range of usize:

Reqwest(reqwest::Error { kind: Decode, source: Error("invalid value: integer `1687816895442`, expected usize", line: 1, column: 35) })

And my collection isn't that big, around 12k cards at most.

I have been getting errors when I use guiCurrentCard and other note/card related APIs, it turns out my note id are outside of the range of usize: ``` Reqwest(reqwest::Error { kind: Decode, source: Error("invalid value: integer `1687816895442`, expected usize", line: 1, column: 35) }) ``` And my collection isn't that big, around 12k cards at most.
eljamm commented 2024-11-04 12:55:47 +00:00 (Migrated from gitlab.com)

@Madoshakalaka Are you on a 32-bit system per chance?

According to usize definition, the maximum representation is 18446744073709551615 (2^64 − 1) on 64-bit targets. For 32-bit, it would be 4294967295 (2^32 − 1), which is less than your card id 1687816895442.

If not, can you share an example that reproduces this?

@Madoshakalaka Are you on a 32-bit system per chance? According to [usize definition](https://doc.rust-lang.org/std/primitive.usize.html), the maximum representation is `18446744073709551615` (2^64 − 1) on 64-bit targets. For 32-bit, it would be `4294967295` (2^32 − 1), which is less than your card id `1687816895442`. If not, can you share an example that reproduces this?
Madoshakalaka commented 2024-11-04 14:03:14 +00:00 (Migrated from gitlab.com)

OHHH, I'm on my 64 bit PC but I was actually using anki_bridge in wasm with reqwest_async, compiled into an web-app in the browser, that must be why.

I cloned the code and changed it to u64 and it worked well
(And I had to tweak the code a bit, had to do maybe_async(?Send) in wasm for example)

OHHH, I'm on my 64 bit PC but I was actually using anki_bridge in wasm with reqwest_async, compiled into an web-app in the browser, that must be why. I cloned the code and changed it to u64 and it worked well (And I had to tweak the code a bit, had to do `maybe_async(?Send)` in wasm for example)
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
kerkmann/anki_bridge#3
No description provided.