use
{
crate :: { TokioCt } ,
std :: { rc::Rc } ,
tokio :: { task::LocalSet, runtime::Builder } ,
};
#[ derive(Debug) ]
#[ cfg_attr( nightly, doc(cfg( feature = "tokio_ct" )) ) ]
pub struct TokioCtBuilder
{
builder: Builder,
}
impl TokioCtBuilder
{
pub fn new() -> Self
{
Self
{
builder: Builder::new_current_thread(),
}
}
pub fn tokio_builder( &mut self ) -> &mut Builder
{
&mut self.builder
}
pub fn build( &mut self ) -> Result<TokioCt, std::io::Error>
{
#[ cfg( feature = "tokio_io" ) ]
self.builder.enable_io();
#[ cfg( feature = "tokio_timer" ) ]
self.builder.enable_time();
let exec = self.builder.build()?;
Ok( TokioCt
{
exec : Rc::new( exec ) ,
local: Rc::new( LocalSet::new() ) ,
})
}
}
impl Default for TokioCtBuilder
{
fn default() -> Self
{
Self::new()
}
}