feat: nicer debug repr for instr id and socketidx

This commit is contained in:
multisn8 2024-01-20 17:59:21 +01:00
parent 0dae38cae8
commit c36a17d313
Signed by: multisamplednight
GPG key ID: 6D525AA147CBDAE2

View file

@ -15,15 +15,23 @@
//! The distinction between [`Input`] and [`Output`] is implemented
//! as them being different types.
use std::fmt;
use serde::{Deserialize, Serialize};
/// One specific instruction.
///
/// It does **not** contain what kind of instruction this is.
/// Refer to [`crate::instruction::Kind`] for this instead.
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
pub struct Instruction(pub(super) u64);
impl fmt::Debug for Instruction {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "InstrId {}", self.0)
}
}
/// On an **instruction**, accepts incoming data.
///
/// An **instruction** cannot run if any of these are not connected.
@ -66,5 +74,11 @@ pub struct Socket {
///
/// This really only serves for denoting where a socket is,
/// when it's already clear which instruction is referred to.
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
pub struct SocketIdx(pub u16);
impl fmt::Debug for SocketIdx {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.0.fmt(f)
}
}