pub(crate) fn register(&mut self) -> Result<(), Error> {
        assert_eq!(self.state, 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);
                }
                self.children.iter_mut().map(|c| c.close()).for_each(drop);
                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) fn register(&mut self) -> Result<(), Error> {
        assert_eq!(self.state, 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);
                }
                self.children.iter_mut().map(|c| c.close()).for_each(drop);
                self.set_state(NexusState::Closed);
                Err(err).context(RegisterNexus {
                    name: self.name.clone(),
                })
            }
        }
    }
pub ( crate ) fn register ( & mut self ) -> Result < ( ) , Error > { assert_eq ! ( self state 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 ) ; } self . children . iter_mut ( ) . map ( | c | c . close ( ) ) . for_each ( drop ) ; 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
&mut self