Repository: duesee/imap-codec (language: rust)

Issue:
building imap-types  fails on Debian `armel` architecture: unresolved import `std::sync::atomic::AtomicU64
Thanks for writing imap-codec and imap-types!

I have packaged these crates for Debian, but imap-types fails to build on the armel architecture, like this:
```
104s error[E0432]: unresolved import `std::sync::atomic::AtomicU64`
104s   --> src/core.rs:38:25
104s    |
104s 38 | use std::sync::atomic::{AtomicU64, Ordering};
104s    |                         ^^^^^^^^^
104s    |                         |
104s    |                         no `AtomicU64` in `sync::atomic`
104s    |                         help: a similar name exists in the module: `AtomicU32`
```

I guess (yet untested!) that it should work using the crate portable_atomics, like this:
```diff
--- a/imap-types/Cargo.toml
+++ b/imap-types/Cargo.toml
@@ -32,6 +32,7 @@
 bounded-static-derive = { version = "0.8.0", default-features = false }
 bounded-static = { version = "0.8.0", default-features = false, features = ["alloc"] }
 chrono = { version = "0.4", default-features = false }
+portable-atomic = "1"
 rand = { version = "0.8", default-features = false, features = ["std", "std_rng"], optional = true }
 serde = { version = "1.0.210", features = ["derive"], optional = true }
 thiserror = "1.0.63"
--- a/imap-types/src/core.rs
+++ b/imap-types/src/core.rs
@@ -35,7 +35,9 @@
 //! ```
.
 #[cfg(feature = "tag_generator")]
-use std::sync::atomic::{AtomicU64, Ordering};
+use std::sync::atomic::Ordering;
+#[cfg(feature = "tag_generator")]
+use portable_atomic::AtomicU64;
 use std::{
     borrow::Cow,
     fmt::{Debug, Display, Formatter},
```

I wonder, however, if 64 bits are crucially needed, or perhaps a better (as in "adequate" and simpler portable) fix might be to change to use AtomicUsize instead?


Discussion / hints:
Hey @jonassmedegaard, thank you for the kind words (and for the packaging!)

I think you are right about just using `AtomicUsize`. I'll be on a trip next week w/o my personal laptop. But, if you are in a position to make a PR (and test on your machine), we could quickly fix :-)

Fix patch:
diff --git a/imap-types/src/core.rs b/imap-types/src/core.rs
index 91efe5b6..9c38fb4e 100644
--- a/imap-types/src/core.rs
+++ b/imap-types/src/core.rs
@@ -35,7 +35,7 @@
 //! ```
 
 #[cfg(feature = "tag_generator")]
-use std::sync::atomic::{AtomicU64, Ordering};
+use std::sync::atomic::{AtomicUsize, Ordering};
 use std::{
     borrow::Cow,
     fmt::{Debug, Display, Formatter},
@@ -57,7 +57,7 @@ use crate::utils::indicators::{
 };
 
 #[cfg(feature = "tag_generator")]
-static GLOBAL_TAG_GENERATOR_COUNT: AtomicU64 = AtomicU64::new(0);
+static GLOBAL_TAG_GENERATOR_COUNT: AtomicUsize = AtomicUsize::new(0);
 
 macro_rules! impl_try_from {
     ($via:ty, $lifetime:lifetime, $from:ty, $target:ty) => {
@@ -1142,7 +1142,7 @@ impl<'a> AsRef<str> for Tag<'a> {
 #[cfg_attr(docsrs, doc(cfg(feature = "tag_generator")))]
 #[derive(Debug)]
 pub struct TagGenerator {
-    global: u64,
+    global: usize,
     counter: u64,
 }
 


Test patch: