v2/item/gdbcall: Reorganize
Define constants/enums after the type and trait definitions for clarity.
Also fixed incorrect ordering of enums - 0x01 comes after 0x00, not 0x02
use core::mem::size_of;
+/// Payload of an [`Item`](super::Item) of [`Kind::Gdbcall`](super::Kind::Gdbcall).
+#[derive(Clone, Copy, Debug, PartialEq)]
+#[repr(C, align(8))]
+pub struct Payload {
+ pub num: Number,
+ pub argv: [usize; 4],
+ pub ret: usize,
+}
+
+pub(crate) const USIZE_COUNT: usize = size_of::<Payload>() / size_of::<usize>();
+
+impl From<&mut [usize; USIZE_COUNT]> for &mut Payload {
+ #[inline]
+ fn from(buf: &mut [usize; USIZE_COUNT]) -> Self {
+ debug_assert_eq!(size_of::<Payload>(), USIZE_COUNT * size_of::<usize>());
+ unsafe { &mut *(buf as *mut _ as *mut _) }
+ }
+}
+
#[derive(Clone, Copy, Debug, PartialEq)]
#[repr(usize)]
/// Number of an [`Item`](super::Item) of [`Kind::Gdbcall`](super::Kind::Gdbcall).
@@ -15,45 +34,26 @@ pub enum Number {
feature = "doc",
doc = "Call number coresponding to [gdbstub::conn::Connection::write_all]"
)]
- WriteAll = 0x02,
+ WriteAll = 0x01,
#[cfg_attr(
feature = "doc",
doc = "Call number coresponding to [gdbstub::conn::Connection::flush]"
)]
- Flush = 0x03,
+ Flush = 0x02,
#[cfg_attr(
feature = "doc",
doc = "Call number coresponding to [gdbstub::conn::Connection::on_session_start]"
)]
- OnSessionStart = 0x04,
+ OnSessionStart = 0x03,
#[cfg_attr(
feature = "doc",
doc = "Call number coresponding to [gdbstub::conn::ConnectionExt::read]"
)]
- Read = 0x05,
+ Read = 0x04,
#[cfg_attr(
feature = "doc",
doc = "Call number coresponding to [gdbstub::conn::ConnectionExt::peek]"
)]
- Peek = 0x06,
-}
-
-/// Payload of an [`Item`](super::Item) of [`Kind::Gdbcall`](super::Kind::Gdbcall).
-#[derive(Clone, Copy, Debug, PartialEq)]
-#[repr(C, align(8))]
-pub struct Payload {
- pub num: Number,
- pub argv: [usize; 4],
- pub ret: usize,
-}
-
-pub(crate) const USIZE_COUNT: usize = size_of::<Payload>() / size_of::<usize>();
-
-impl From<&mut [usize; USIZE_COUNT]> for &mut Payload {
- #[inline]
- fn from(buf: &mut [usize; USIZE_COUNT]) -> Self {
- debug_assert_eq!(size_of::<Payload>(), USIZE_COUNT * size_of::<usize>());
- unsafe { &mut *(buf as *mut _ as *mut _) }
- }
+ Peek = 0x05,
}
