header file Raw Rust bindings Safe Rust bindings pub fn lookup_config(id: u32) -> Result<Self, DmaError> { let ptr = unsafe { esys::XAxiDma_LookupConfig(id) }; if ptr.is_null() { Err(DmaError::ConfigInit) } else { Ok(Self { config: ptr }) } } extern "C" { pub fn XAxiDma_LookupConfig( DeviceId: u32_, ) -> *mut XAxiDma_Config; } XAxiDma_Config *XAxiDma_LookupConfig(u32 DeviceId); • nullチェック • 返り値を列挙型に変更 ⟹ 安全かつエラーハンドリングを容易にする