pub(crate) async fn register(&mut self) -> Result<(), Error> {
        assert_eq!(*self.state.lock().unwrap(), NexusState::Init);

        unsafe {
            spdk_io_device_register(
                self.as_ptr(),
                Some(NexusChannel::create),
                Some(NexusChannel::destroy),
                std::mem::size_of::<NexusChannel>() as u32,
                (*self.bdev.as_ptr()).name,
            );
        }

        debug!("{}: IO device registered at {:p}", self.name, self.as_ptr());

        let errno = unsafe { spdk_bdev_register(self.bdev.as_ptr()) };

        match errno_result_from_i32((), errno) {
            Ok(_) => {
                self.set_state(NexusState::Open);
                Ok(())
            }
            Err(err) => {
                unsafe {
                    spdk_io_device_unregister(self.as_ptr(), None);
                }
                for child in &mut self.children {
                    if let Err(e) = child.close().await {
                        error!(
                            "{}: child {} failed to close with error {}",
                            self.name,
                            child.name,
                            e.verbose()
                        );
                    }
                }
                self.set_state(NexusState::Closed);
                Err(err).context(RegisterNexus {
                    name: self.name.clone(),
                })
            }
        }
    }
/// register the bdev with SPDK and set the callbacks for io channel
/// creation. Once this function is called, the device is visible and can
/// be used for IO.
register the bdev with SPDK and set the callbacks for io channel
creation. Once this function is called, the device is visible and can
be used for IO.
register the bdev with SPDK and set the callbacks for io channel creation . Once this function is called the device is visible and can be used for IO .
pub(crate) async fn register(&mut self) -> Result<(), Error> {
        assert_eq!(*self.state.lock().unwrap(), NexusState::Init);
        unsafe {
            spdk_io_device_register(
                self.as_ptr(),
                Some(NexusChannel::create),
                Some(NexusChannel::destroy),
                std::mem::size_of::<NexusChannel>() as u32,
                (*self.bdev.as_ptr()).name,
            );
        }
        debug!("{}: IO device registered at {:p}", self.name, self.as_ptr());
        let errno = unsafe { spdk_bdev_register(self.bdev.as_ptr()) };
        match errno_result_from_i32((), errno) {
            Ok(_) => {
                self.set_state(NexusState::Open);
                Ok(())
            }
            Err(err) => {
                unsafe {
                    spdk_io_device_unregister(self.as_ptr(), None);
                }
                for child in &mut self.children {
                    if let Err(e) = child.close().await {
                        error!(
                            "{}: child {} failed to close with error {}",
                            self.name,
                            child.name,
                            e.verbose()
                        );
                    }
                }
                self.set_state(NexusState::Closed);
                Err(err).context(RegisterNexus {
                    name: self.name.clone(),
                })
            }
        }
    }
pub ( crate ) async fn register ( & mut self ) -> Result < ( ) , Error > { assert_eq ! ( self state lock ( ) unwrap ( ) NexusState Init ) ; unsafe { spdk_io_device_register ( self . as_ptr ( ) , Some ( NexusChannel :: create ) , Some ( NexusChannel :: destroy ) , std :: mem :: size_of :: < NexusChannel > ( ) as u32 , ( * self . bdev . as_ptr ( ) ) . name , ) ; } debug ! ( " " self name self as_ptr ( ) ) ; let errno = unsafe { spdk_bdev_register ( self . bdev . as_ptr ( ) ) } ; match errno_result_from_i32 ( ( ) , errno ) { Ok ( _ ) => { self . set_state ( NexusState :: Open ) ; Ok ( ( ) ) } Err ( err ) => { unsafe { spdk_io_device_unregister ( self . as_ptr ( ) , None ) ; } for child in & mut self . children { if let Err ( e ) = child . close ( ) . await { error ! ( " " self name child name e verbose ( ) ) ; } } self . set_state ( NexusState :: Closed ) ; Err ( err ) . context ( RegisterNexus { name : self . name . clone ( ) , } ) } } }
register the bdev with SPDK and set the callbacks for io channel
creation.
register the bdev with SPDK and set the callbacks for io channel creation .
&mut self