diff options
| author | Fuwn <[email protected]> | 2022-01-03 14:27:39 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2022-01-03 14:27:39 -0800 |
| commit | 057a8eeb023ce07e971e9ed98111a269df8049bb (patch) | |
| tree | 50ee379be6d695ae7a788b3df8101f0f1a1207c2 /crates/windows-kernel-rs/src/ioctl.rs | |
| parent | fix(windows-kernel-rs): traits (diff) | |
| download | driver-057a8eeb023ce07e971e9ed98111a269df8049bb.tar.xz driver-057a8eeb023ce07e971e9ed98111a269df8049bb.zip | |
fix(windows-kernel-rs): impl Into to impl From
Diffstat (limited to 'crates/windows-kernel-rs/src/ioctl.rs')
| -rw-r--r-- | crates/windows-kernel-rs/src/ioctl.rs | 46 |
1 files changed, 33 insertions, 13 deletions
diff --git a/crates/windows-kernel-rs/src/ioctl.rs b/crates/windows-kernel-rs/src/ioctl.rs index c1d493f..9f1d2e7 100644 --- a/crates/windows-kernel-rs/src/ioctl.rs +++ b/crates/windows-kernel-rs/src/ioctl.rs @@ -41,13 +41,23 @@ impl From<u32> for TransferMethod { } } -impl Into<u32> for TransferMethod { - fn into(self) -> u32 { - match self { - Self::Neither => METHOD_NEITHER, - Self::InputDirect => METHOD_IN_DIRECT, - Self::OutputDirect => METHOD_OUT_DIRECT, - Self::Buffered => METHOD_BUFFERED, +// impl Into<u32> for TransferMethod { +// fn into(self) -> u32 { +// match self { +// Self::Neither => METHOD_NEITHER, +// Self::InputDirect => METHOD_IN_DIRECT, +// Self::OutputDirect => METHOD_OUT_DIRECT, +// Self::Buffered => METHOD_BUFFERED, +// } +// } +// } +impl From<TransferMethod> for u32 { + fn from(t: TransferMethod) -> Self { + match t { + TransferMethod::Neither => METHOD_NEITHER, + TransferMethod::InputDirect => METHOD_IN_DIRECT, + TransferMethod::OutputDirect => METHOD_OUT_DIRECT, + TransferMethod::Buffered => METHOD_BUFFERED, } } } @@ -99,12 +109,22 @@ impl From<u32> for ControlCode { } } -impl Into<u32> for ControlCode { - fn into(self) -> u32 { - let method = Into::<u32>::into(self.3) << Self::METHOD_SHIFT; - let num = self.2 << Self::NUM_SHIFT; - let access = self.1.bits() << Self::ACCESS_SHIFT; - let ty = Into::<u32>::into(self.0) << Self::TYPE_SHIFT; +// impl Into<u32> for ControlCode { +// fn into(self) -> u32 { +// let method = Into::<u32>::into(self.3) << Self::METHOD_SHIFT; +// let num = self.2 << Self::NUM_SHIFT; +// let access = self.1.bits() << Self::ACCESS_SHIFT; +// let ty = Into::<u32>::into(self.0) << Self::TYPE_SHIFT; +// +// ty | access | num | method +// } +// } +impl From<ControlCode> for u32 { + fn from(c: ControlCode) -> Self { + let method = Into::<u32>::into(c.3) << ControlCode::METHOD_SHIFT; + let num = c.2 << ControlCode::NUM_SHIFT; + let access = c.1.bits() << ControlCode::ACCESS_SHIFT; + let ty = Into::<u32>::into(c.0) << ControlCode::TYPE_SHIFT; ty | access | num | method } |