/// Creates a new instance of the CommsControlBlock
Creates a new instance of the CommsControlBlock
Creates a new instance of the CommsControlBlock
pub fn new(
        read: Option<Arc<ReadFn<ReadConnection>>>,
        write: Vec<Arc<WriteFn<WriteConnection>>>,
        read_conn: ReadConnection,
        write_conn: WriteConnection,
        config: CommsConfig,
    ) -> CommsResult<Self> {
        if write.is_empty() {
            return Err(
                CommsServiceError::ConfigError("No `write` function provided".to_owned()).into(),
            );
        }
        if let Some(ports) = config.clone().downlink_ports {
            if write.len() != ports.len() {
                return Err(CommsServiceError::ConfigError(
                    "There must be a unique write function for each downlink port".to_owned(),
                )
                .into());
            }
        }
        Ok(CommsControlBlock {
            read,
            write,
            read_conn,
            write_conn,
            max_num_handlers: config.max_num_handlers.unwrap_or(DEFAULT_MAX_HANDLERS),
            read_timeout: config.read_timeout.unwrap_or(DEFAULT_TIMEOUT),
            write_timeout: config.write_timeout.unwrap_or(DEFAULT_TIMEOUT),
            ip: Ipv4Addr::from_str(&config.ip)?,
            downlink_ports: config.downlink_ports,
        })
    }
pub fn new ( read : Option < Arc < ReadFn < ReadConnection > > > , write : Vec < Arc < WriteFn < WriteConnection > > > , read_conn : ReadConnection , write_conn : WriteConnection , config : CommsConfig , ) -> CommsResult < Self > { if write . is_empty ( ) { return Err ( CommsServiceError :: ConfigError ( " " . to_owned ( ) ) . into ( ) , ) ; } if let Some ( ports ) = config . clone ( ) . downlink_ports { if write . len ( ) != ports . len ( ) { return Err ( CommsServiceError :: ConfigError ( " " . to_owned ( ) , ) . into ( ) ) ; } } Ok ( CommsControlBlock { read , write , read_conn , write_conn , max_num_handlers : config . max_num_handlers . unwrap_or ( DEFAULT_MAX_HANDLERS ) , read_timeout : config . read_timeout . unwrap_or ( DEFAULT_TIMEOUT ) , write_timeout : config . write_timeout . unwrap_or ( DEFAULT_TIMEOUT ) , ip : Ipv4Addr :: from_str ( & config . ip ) ? , downlink_ports : config . downlink_ports , } ) }
Creates a new instance of the CommsControlBlock
Creates a new instance of the CommsControlBlock
read
Option<Arc<ReadFn<ReadConnection>>>
write
Vec<Arc<WriteFn<WriteConnection>>>
read_conn
ReadConnection
write_conn
WriteConnection
config
CommsConfig