Trait default impl call Self impl without wrapper

Hello, I'm doing Operating System development.
I have a trait for MSR register logic.
Currently, I have the following:

pub trait Msr {
    const MSR_NUM: u32;

    fn from_bytes(bytes: [u8; 8]) -> Self;
    fn into_bytes(self) -> [u8; 8];

    /// # Safety
    /// The caller must ensure that this operation has no unsafe side effects.
    unsafe fn read() -> Self
    where
        Self: Sized,
    {
        let (low, high): (u32, u32);
        asm!("rdmsr", in("ecx") Self::MSR_NUM, out("eax") low, out("edx") high, options(nomem, nostack, preserves_flags));
        Self::from_bytes(((u64::from(high) << 32) | u64::from(low)).to_le_bytes())
    }
    /// # Safety
    /// The caller must ensure that this operation has no unsafe side effects.
    unsafe fn write(&self)
    where
        Self: Sized + Copy,
    {
        let value = u64::from_le_bytes(Self::into_bytes(*self));
        let (low, high): (u32, u32) = (value as u32, (value >> 32) as u32);
        asm!("wrmsr", in("ecx") Self::MSR_NUM, in("eax") low, in("edx") high, options(nomem, nostack, preserves_flags));
    }
}

I don't want the wrapper trait functions from_bytes and into_bytes:

impl super::Msr for Efer {
    const MSR_NUM: u32 = 0xC000_0080;

    fn from_bytes(bytes: [u8; 8]) -> Self {
        Self::from_bytes(bytes)
    }

    fn into_bytes(self) -> [u8; 8] {
        Efer::into_bytes(self)
    }
}

I want it to look like:

impl super::Msr for Efer {
    const MSR_NUM: u32 = 0xC000_0080;
}

Is this possible?

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.