1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
//! Extended account database module.
#[cfg(any(target_os = "linux", target_os = "macos"))]
use std::ffi::CString;
use std::{
    collections::{hash_set, HashSet},
    convert::TryFrom,
    error::Error as StdError,
    fmt::{self, Display},
    io,
    path::Path,
};
#[cfg(not(any(target_os = "linux", target_os = "macos")))]
use std::{
    fs::{self, File},
    io::{BufReader, Read},
    mem, slice,
};

use super::{Pid, TimeVal};

#[cfg(any(target_os = "linux", target_os = "netbsd"))]
use libc::__exit_status as ExitStatus;
#[cfg(all(target_os = "linux", any(target_arch = "x86_64")))]
use libc::c_int;
#[cfg(all(target_os = "linux", not(any(target_arch = "x86_64"))))]
use libc::c_long;
#[cfg(any(target_os = "linux", target_os = "macos"))]
use libc::utmpxname;
#[cfg(target_os = "solaris")]
use libc::{c_int, c_short, exit_status as ExitStatus};
use libc::{endutxent, getutxent, setutxent, suseconds_t, time_t, utmpx};

use bstr::{BStr, BString, ByteSlice};

use time::{Duration, OffsetDateTime as DateTime};

/// Error type for [`UtmpxKind`] conversion.
#[derive(Debug, PartialEq, PartialOrd, Eq, Ord, Hash)]
pub enum Error {
    /// When the OS has not this [`UtmpxKind`] and a number related to that kind.
    OsNoKind,
    /// When the OS has no [`UtmpxKind`] related to this number.
    OsNoNumber,
}

impl StdError for Error {
    fn source(&self) -> Option<&(dyn StdError + 'static)> { None }
}

impl Display for Error {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        match self {
            Self::OsNoKind => {
                write!(f, "This OS has not this UtmpxKind and a number related to that kind")
            },
            Self::OsNoNumber => write!(f, "This OS has no UtmpxKind related to this number"),
        }
    }
}

/// Possible types of a [`Utmpx`] instance.
#[repr(u16)]
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum UtmpxKind {
    /// Not sure yet. (Linux and MacOS exclusive)
    Accounting,
    /// Time of a system boot.
    BootTime,
    /// A session leader exited.
    DeadProcess,
    /// No valid user accounting information.
    Empty,
    /// A process spawned by init(8).
    InitProcess,
    /// The session leader of a logged-in user.
    LoginProcess,
    /// Time after system clock change.
    NewTime,
    /// Time before system clock change.
    OldTime,
    /// Run level. Provided for compatibility, not used on NetBSD.
    RunLevel,
    /// Not sure yet. (MacOS exclusive)
    Signature,
    /// The session leader of a time of system shutdown.
    ShutdownProcess,
    // A user process.
    UserProcess,
    // Not sure yet.
    DownTime,
}

/// A struct that represents a __user__ account, where user can be humam users or other
/// parts of the system that requires the usage of account structure, like some daemons.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Utmpx {
    /// User login name.
    user:    BString,
    /// Host name.
    host:    BString,
    /// Process id creating the entry.
    pid:     Pid,
    /// Record identifier. (/etc/inittab id)
    id:      BString,
    /// Device name. (console/tty, lnxx)
    line:    BString,
    /// Type of the entry.
    ut_type: UtmpxKind,
    /// The time entry was created.
    timeval: TimeVal, // tv
    #[cfg(any(target_os = "linux", target_os = "netbsd", target_os = "solaris"))]
    exit:    ExitStatus,
    /// Session ID. (used for windowing)
    #[cfg(all(target_os = "linux", any(target_arch = "x86_64")))]
    session: c_int,
    /// Session ID. (used for windowing)
    #[cfg(target_os = "solaris")]
    session: c_int,
    /// Session ID. (used for windowing)
    #[cfg(all(target_os = "linux", not(any(target_arch = "x86_64"))))]
    session: c_long,
    /// Session ID. (used for windowing)
    #[cfg(any(target_os = "netbsd", target_os = "dragonfly"))]
    session: u16,
    #[cfg(target_os = "linux")]
    addr_v6: [i32; 4],
    #[cfg(target_os = "netbsd")]
    ss:      libc::sockaddr_storage,
    #[cfg(target_os = "solaris")]
    syslen:  c_short,
}

impl Utmpx {
    /// Creates a new [`Utmpx`] entry from the `C` version of the structure.
    pub fn from_c_utmpx(utm: utmpx) -> Self { Self::from(utm) }

    /// Get user name.
    pub fn user(&self) -> &BStr { self.user.as_bstr() }

    /// Get host name.
    pub fn host(&self) -> &BStr { self.host.as_bstr() }

    /// Get the process ID.
    pub fn process_id(&self) -> Pid { self.pid }

    /// Get the record ID.
    pub fn id(&self) -> &BStr { self.id.as_bstr() }

    /// Get the device name of the entry (usually a tty or console).
    pub fn device_name(&self) -> &BStr { self.line.as_bstr() }

    /// Get the type kind if the entry.
    pub const fn entry_type(&self) -> UtmpxKind { self.ut_type }

    /// Get the time where the entry was created. (often login time)
    pub const fn timeval(&self) -> TimeVal { self.timeval }

    /// Get the time where the entry was created (often login time) in a more complete
    /// structure.
    pub fn login_time(&self) -> DateTime {
        DateTime::from_unix_timestamp(self.timeval.tv_sec as i64)
            + Duration::microseconds(self.timeval.tv_usec as i64)
    }

    /// Get the session ID of the entry.
    #[cfg(all(target_os = "linux", any(target_arch = "x86_64")))]
    pub const fn session(&self) -> c_int { self.session }

    /// Get the session ID of the entry.
    #[cfg(target_os = "solaris")]
    pub const fn session(&self) -> c_int { self.session }

    /// Get the session ID of the entry.
    #[cfg(all(target_os = "linux", not(any(target_arch = "x86_64"))))]
    pub const fn session(&self) -> c_long { self.session }

    /// Get the session ID of the entry.
    #[cfg(any(target_os = "netbsd", target_os = "dragonfly"))]
    pub const fn session(&self) -> u16 { self.session }

    /// Get v6 address of the entry.
    #[cfg(target_os = "linux")]
    pub const fn v6_addr(&self) -> [i32; 4] { self.addr_v6 }

    /// Get exit status of the entry.
    #[cfg(any(target_os = "linux", target_os = "netbsd", target_os = "solaris"))]
    pub const fn exit_status(&self) -> ExitStatus { self.exit }
}

impl From<utmpx> for Utmpx {
    /// Converts [`utmpx`] to [`Utmpx`].
    ///
    /// # Panic
    /// This function may panic when converting a number to UtmpxKind. Since we get the
    /// number from the OS it should never panic, but if the OS drastically change, it
    /// may panic.
    fn from(c_utmpx: utmpx) -> Self {
        #[cfg(not(any(target_os = "netbsd", target_os = "dragonfly")))]
        let user = {
            let cstr: String = c_utmpx
                .ut_user
                .iter()
                .map(|cc| *cc as u8 as char)
                .filter(|cc| cc != &'\0')
                .collect();
            BString::from(cstr.as_bytes())
        };

        #[cfg(any(target_os = "netbsd", target_os = "dragonfly"))]
        let user = {
            let cstr: String = c_utmpx
                .ut_name
                .iter()
                .map(|cc| *cc as u8 as char)
                .filter(|cc| cc != &'\0')
                .collect();
            BString::from(cstr.as_bytes())
        };

        let host = {
            let cstr: String = c_utmpx
                .ut_host
                .iter()
                .map(|cc| *cc as u8 as char)
                .filter(|cc| cc != &'\0')
                .collect();
            BString::from(cstr.as_bytes())
        };

        let pid = c_utmpx.ut_pid;

        let id = {
            let cstr: String =
                c_utmpx.ut_id.iter().map(|cc| *cc as u8 as char).filter(|cc| cc != &'\0').collect();
            BString::from(cstr.as_bytes())
        };

        let line = {
            let cstr: String = c_utmpx
                .ut_line
                .iter()
                .map(|cc| *cc as u8 as char)
                .filter(|cc| cc != &'\0')
                .collect();
            BString::from(cstr.as_bytes())
        };

        let ut_type = match UtmpxKind::try_from(c_utmpx.ut_type) {
            Ok(ut) => ut,
            Err(err) => panic!(format!("{}", err)),
        };

        let timeval = TimeVal {
            tv_sec:  c_utmpx.ut_tv.tv_sec as time_t,
            tv_usec: c_utmpx.ut_tv.tv_usec as suseconds_t,
        };

        #[cfg(any(
            target_os = "linux",
            target_os = "netbsd",
            target_os = "dragonfly",
            target_os = "solaris"
        ))]
        let session = c_utmpx.ut_session;

        #[cfg(target_os = "linux")]
        let addr_v6 = c_utmpx.ut_addr_v6;

        #[cfg(any(target_os = "linux", target_os = "netbsd", target_os = "solaris"))]
        let exit = c_utmpx.ut_exit;

        #[cfg(any(target_os = "netbsd"))]
        let ss = c_utmpx.ut_ss;

        #[cfg(target_os = "solaris")]
        let syslen = c_utmpx.ut_syslen;

        Utmpx {
            user,
            host,
            pid,
            id,
            line,
            ut_type,
            timeval,
            #[cfg(any(target_os = "linux", target_os = "netbsd", target_os = "solaris"))]
            exit,
            #[cfg(any(
                target_os = "linux",
                target_os = "netbsd",
                target_os = "dragonfly",
                target_os = "solaris"
            ))]
            session,
            #[cfg(target_os = "linux")]
            addr_v6,
            #[cfg(target_os = "netbsd")]
            ss,
            #[cfg(target_os = "solaris")]
            syslen,
        }
    }
}

/// A collection of Utmpx entries.
#[derive(Debug)]
pub struct UtmpxSet(HashSet<Utmpx>);

impl UtmpxSet {
    /// Creates a new collection over a utmpx entry binary file.
    ///
    /// # Errors
    /// If a internal call set a errno (I/O OS error), an error variant will be returned.
    #[cfg(any(target_os = "linux", target_os = "macos"))]
    pub fn from_file(path: impl AsRef<Path>) -> io::Result<Self> {
        let file = {
            let str = match path.as_ref().to_str() {
                Some(s) => s,
                None => "",
            };
            CString::new(str).unwrap_or_default()
        };

        let mut set = HashSet::new();

        unsafe {
            let res = utmpxname(file.as_ptr());

            if res != 0 {
                return Err(io::Error::last_os_error());
            }

            loop {
                let ut = getutxent();
                if ut.is_null() {
                    break;
                } else {
                    let utm = Utmpx::from_c_utmpx(*ut);
                    set.insert(utm);
                }
            }

            endutxent();
        }

        Ok(UtmpxSet(set))
    }

    /// Creates a new collection over a utmpx entry binary file.
    ///
    /// # Errors
    /// If a internal call set a errno (I/O OS error), an error variant will be returned.
    #[cfg(not(any(target_os = "linux", target_os = "macos")))]
    pub fn from_file(path: impl AsRef<Path>) -> io::Result<Self> {
        let struct_size = mem::size_of::<utmpx>();
        let num_bytes = fs::metadata(&path)?.len() as usize;
        let num_structs = num_bytes / struct_size;
        let mut reader = BufReader::new(File::open(&path)?);
        let mut vec = Vec::with_capacity(num_structs);
        let mut set = HashSet::with_capacity(num_structs);

        unsafe {
            let mut buffer = slice::from_raw_parts_mut(vec.as_mut_ptr() as *mut u8, num_bytes);
            reader.read_exact(&mut buffer)?;
            vec.set_len(num_structs);
        }

        for raw_utm in vec {
            set.insert(Utmpx::from_c_utmpx(raw_utm));
        }

        Ok(UtmpxSet(set))
    }

    /// Creates a new collection geting all entries from the running system.
    pub fn system() -> Self {
        let mut set = HashSet::new();

        unsafe {
            setutxent();

            loop {
                let ut = getutxent();
                if ut.is_null() {
                    break;
                } else {
                    let utm = Utmpx::from_c_utmpx(*ut);
                    set.insert(utm);
                }
            }

            endutxent();
        }

        UtmpxSet(set)
    }

    /// Returns `true` if collection nas no elements.
    pub fn is_empty(&self) -> bool { self.0.is_empty() }

    /// Creates a iterator over it's entries.
    pub fn iter(&self) -> hash_set::Iter<'_, Utmpx> { self.0.iter() }

    /// Size of the collection.
    pub fn len(&self) -> usize { self.0.len() }
}

impl IntoIterator for UtmpxSet {
    type IntoIter = hash_set::IntoIter<Utmpx>;
    type Item = Utmpx;

    #[inline]
    fn into_iter(self) -> Self::IntoIter { self.0.into_iter() }
}


// Extra trait
macro_rules! utmpxkind_impl_from {
    ($($t:ty)+) => (
        $(
            // Number to UtmpxKind
            #[cfg(target_os = "freebsd")]
            impl TryFrom<$t> for UtmpxKind {
                type Error = Error;

                fn try_from(num: $t) -> Result<Self, Error> {
                    match num {
                        0 => Ok(Self::Empty),
                        1 => Ok(Self::BootTime),
                        2 => Ok(Self::OldTime),
                        3 => Ok(Self::NewTime),
                        4 => Ok(Self::UserProcess),
                        5 => Ok(Self::InitProcess),
                        6 => Ok(Self::LoginProcess),
                        7 => Ok(Self::DeadProcess),
                        8 => Ok(Self::ShutdownProcess),
                        _ => Err(Error::OsNoNumber),
                    }
                }
            }

            #[cfg(target_os = "netbsd")]
            impl TryFrom<$t> for UtmpxKind {
                type Error = Error;
                fn try_from(num: $t) -> Result<Self, Error> {
                    match num {
                        0 => Ok(Self::Empty),
                        1 => Ok(Self::RunLevel),
                        2 => Ok(Self::BootTime),
                        3 => Ok(Self::OldTime),
                        4 => Ok(Self::NewTime),
                        5 => Ok(Self::InitProcess),
                        6 => Ok(Self::LoginProcess),
                        7 => Ok(Self::UserProcess),
                        8 => Ok(Self::DeadProcess),
                        9 => Ok(Self::Accounting),
                        10 => Ok(Self::Signature),
                        11 => Ok(Self::DownTime),
                        _ => Err(Error::OsNoNumber),
                    }
                }
            }

            #[cfg(any(target_os = "dragonfly"))]
            impl TryFrom<$t> for UtmpxKind {
                type Error = Error;
                fn try_from(num: $t) -> Result<Self, Error> {
                    match num {
                        0 => Ok(Self::Empty),
                        1 => Ok(Self::RunLevel),
                        2 => Ok(Self::BootTime),
                        3 => Ok(Self::NewTime),
                        4 => Ok(Self::OldTime),
                        5 => Ok(Self::InitProcess),
                        6 => Ok(Self::LoginProcess),
                        7 => Ok(Self::UserProcess),
                        8 => Ok(Self::DeadProcess),
                        _ => Err(Error::OsNoNumber),
                    }
                }
            }

            #[cfg(target_os = "solaris")]
            impl TryFrom<$t> for UtmpxKind {
                type Error = Error;
                fn try_from(num: $t) -> Result<Self, Error> {
                    match num {
                        0 => Ok(Self::Empty),
                        1 => Ok(Self::RunLevel),
                        2 => Ok(Self::BootTime),
                        3 => Ok(Self::OldTime),
                        4 => Ok(Self::NewTime),
                        5 => Ok(Self::InitProcess),
                        6 => Ok(Self::LoginProcess),
                        7 => Ok(Self::UserProcess),
                        8 => Ok(Self::DeadProcess),
                        9 => Ok(Self::Accounting),
                        10 => Ok(Self::DownTime),
                        _ => Err(Error::OsNoNumber),
                    }
                }
            }

            #[cfg(any(target_os = "linux", target_os = "macos"))]
            impl TryFrom<$t> for UtmpxKind {
                type Error = Error;
                fn try_from(num: $t) -> Result<Self, Error> {
                    match num {
                        0 => Ok(Self::Empty),
                        1 => Ok(Self::RunLevel),
                        2 => Ok(Self::BootTime),
                        3 => Ok(Self::NewTime),
                        4 => Ok(Self::OldTime),
                        5 => Ok(Self::InitProcess),
                        6 => Ok(Self::LoginProcess),
                        7 => Ok(Self::UserProcess),
                        8 => Ok(Self::DeadProcess),
                        9 => Ok(Self::Accounting),
                        #[cfg(target_os = "macos")]
                        10 => Ok(Self::Signature),
                        #[cfg(target_os = "macos")]
                        11 => Ok(Self::ShutdownProcess),
                        _ => Err(Error::OsNoNumber),
                    }
                }
            }

            // UtmpxKind to number
            #[cfg(target_os = "freebsd")]
            impl TryFrom<UtmpxKind> for $t {
                type Error = Error;
                fn try_from(utype: UtmpxKind) -> Result<Self, Error> {
                    match utype {
                        UtmpxKind::Empty => Ok(0),
                        UtmpxKind::BootTime => Ok(1),
                        UtmpxKind::OldTime => Ok(2),
                        UtmpxKind::NewTime => Ok(3),
                        UtmpxKind::UserProcess => Ok(4),
                        UtmpxKind::InitProcess => Ok(5),
                        UtmpxKind::LoginProcess => Ok(6),
                        UtmpxKind::DeadProcess => Ok(7),
                        UtmpxKind::ShutdownProcess => Ok(8),
                        _ => Err(Error::OsNoKind),
                    }
                }
            }

            #[cfg(target_os = "netbsd")]
            impl TryFrom<UtmpxKind> for $t {
                type Error = Error;
                fn try_from(utype: UtmpxKind) -> Result<Self, Error> {
                    match utype {
                        UtmpxKind::Empty => Ok(0),
                        UtmpxKind::RunLevel => Ok(1),
                        UtmpxKind::BootTime => Ok(2),
                        UtmpxKind::OldTime => Ok(3),
                        UtmpxKind::NewTime => Ok(4),
                        UtmpxKind::InitProcess => Ok(5),
                        UtmpxKind::LoginProcess => Ok(6),
                        UtmpxKind::UserProcess => Ok(7),
                        UtmpxKind::DeadProcess => Ok(8),
                        UtmpxKind::Accounting => Ok(9),
                        UtmpxKind::Signature => Ok(10),
                        UtmpxKind::DownTime => Ok(11),
                        _ => Err(Error::OsNoKind),
                    }
                }
            }

            #[cfg(any(target_os = "dragonfly"))]
            impl TryFrom<UtmpxKind> for $t {
                type Error = Error;
                fn try_from(utype: UtmpxKind) -> Result<Self, Error> {
                    match utype {
                        UtmpxKind::Empty => Ok(0),
                        UtmpxKind::RunLevel => Ok(1),
                        UtmpxKind::BootTime => Ok(2),
                        UtmpxKind::NewTime => Ok(3),
                        UtmpxKind::OldTime => Ok(4),
                        UtmpxKind::InitProcess => Ok(5),
                        UtmpxKind::LoginProcess => Ok(6),
                        UtmpxKind::UserProcess => Ok(7),
                        UtmpxKind::DeadProcess => Ok(8),
                        _ => Err(Error::OsNoKind),
                    }
                }
            }

            #[cfg(target_os = "solaris")]
            impl TryFrom<UtmpxKind> for $t {
                type Error = Error;
                fn try_from(utype: UtmpxKind) -> Result<Self, Error> {
                    match utype {
                        UtmpxKind::Empty => Ok(0),
                        UtmpxKind::RunLevel => Ok(1),
                        UtmpxKind::BootTime => Ok(2),
                        UtmpxKind::OldTime => Ok(3),
                        UtmpxKind::NewTime => Ok(4),
                        UtmpxKind::InitProcess => Ok(5),
                        UtmpxKind::LoginProcess => Ok(6),
                        UtmpxKind::UserProcess => Ok(7),
                        UtmpxKind::DeadProcess => Ok(8),
                        UtmpxKind::Accounting => Ok(9),
                        UtmpxKind::DownTime => Ok(10),
                        _ => Err(Error::OsNoKind),
                    }
                }
            }

            #[cfg(any(target_os = "linux", target_os = "macos"))]
            impl TryFrom<UtmpxKind> for $t {
                type Error = Error;
                fn try_from(utype: UtmpxKind) -> Result<Self, Error> {
                    match utype {
                        UtmpxKind::Empty => Ok(0),
                        UtmpxKind::RunLevel => Ok(1),
                        UtmpxKind::BootTime => Ok(2),
                        UtmpxKind::NewTime => Ok(3),
                        UtmpxKind::OldTime => Ok(4),
                        UtmpxKind::InitProcess => Ok(5),
                        UtmpxKind::LoginProcess => Ok(6),
                        UtmpxKind::UserProcess => Ok(7),
                        UtmpxKind::DeadProcess => Ok(8),
                        UtmpxKind::Accounting => Ok(9),
                        #[cfg(target_os = "macos")]
                        UtmpxKind::Signature => Ok(10),
                        #[cfg(target_os = "macos")]
                        UtmpxKind::ShutdownProcess => Ok(11),
                        _ => Err(Error::OsNoKind),
                    }
                }
            }
        )+
    );
}

utmpxkind_impl_from!(i8 i16 i32 i64 i128 u8 u16 u32 u64 u128);