springql-core-release-test 1.0.0-a6

SpringQL: Open-source stream processor for IoT devices and in-vehicle computers
Documentation
// This file is part of https://github.com/SpringQL/SpringQL which is licensed under MIT OR Apache-2.0. See file LICENSE-MIT or LICENSE-APACHE for full license details.

use crate::{
    api::{error::Result, SpringSourceReaderConfig},
    pipeline::{Options, SourceReaderType},
    stream_engine::autonomous_executor::task::source_task::source_reader::{
        can::CANSourceReader, net_client::NetClientSourceReader, net_server::NetServerSourceReader,
        InMemoryQueueSourceReader, SourceReader,
    },
};

pub struct SourceReaderFactory;

impl SourceReaderFactory {
    pub fn source(
        source_reader_type: &SourceReaderType,
        options: &Options,
        config: &SpringSourceReaderConfig,
    ) -> Result<Box<dyn SourceReader>> {
        match source_reader_type {
            SourceReaderType::NetClient => {
                Ok(Box::new(NetClientSourceReader::start(options, config)?))
            }
            SourceReaderType::NetServer => {
                Ok(Box::new(NetServerSourceReader::start(options, config)?))
            }
            SourceReaderType::CAN => Ok(Box::new(CANSourceReader::start(options, config)?)),
            SourceReaderType::InMemoryQueue => {
                Ok(Box::new(InMemoryQueueSourceReader::start(options, config)?))
            }
        }
    }
}