pub async fn new<F>(runtime: Runtime, f: F) -> Result<Self, E>
    where
        F: FnOnce() -> Result<T, E> + Send + 'static,
    {
        let result = match runtime.spawn_blocking(move || f()).await {
            // FIXME: Panicking when the creation panics is not nice.
            // In order to handle this properly the Manager::create
            // methods needs to support a custom error enum which
            // supports a Panic variant.
            Err(SpawnBlockingError::Panic(e)) => panic!("{:?}", e),
            Ok(obj) => obj,
        };
        result.map(|obj| Self {
            obj: Arc::new(Mutex::new(Some(obj))),
            runtime,
            _error: PhantomData::default(),
        })
    }
/// Creates a new wrapped object.
Creates a new wrapped object.
Creates a new wrapped object .
pub async fn new<F>(runtime: Runtime, f: F) -> Result<Self, E>
    where
        F: FnOnce() -> Result<T, E> + Send + 'static,
    {
        let result = match runtime.spawn_blocking(move || f()).await {
            // FIXME: Panicking when the creation panics is not nice.
            // In order to handle this properly the Manager::create
            // methods needs to support a custom error enum which
            // supports a Panic variant.
            Err(SpawnBlockingError::Panic(e)) => panic!("{:?}", e),
            Ok(obj) => obj,
        };
        result.map(|obj| Self {
            obj: Arc::new(Mutex::new(Some(obj))),
            runtime,
            _error: PhantomData::default(),
        })
    }
pub async fn new < F > ( runtime : Runtime , f : F ) -> Result < Self , E > where F : FnOnce ( ) -> Result < T , E > + Send + ' static , { let result = match runtime . spawn_blocking ( move | | f ( ) ) . await { // FIXME: Panicking when the creation panics is not nice. // In order to handle this properly the Manager::create // methods needs to support a custom error enum which // supports a Panic variant. Err ( SpawnBlockingError :: Panic ( e ) ) => panic ! ( " " e ) , Ok ( obj ) => obj , } ; result . map ( | obj | Self { obj : Arc :: new ( Mutex :: new ( Some ( obj ) ) ) , runtime , _error : PhantomData :: default ( ) , } ) }
Creates a new wrapped object.
Creates a new wrapped object .
runtime
Runtime
f
F
runtime
Runtime
f
F