pub trait InputFormat: Send + Sync {
// Required methods
fn name(&self) -> Cow<'static, str>;
fn config_from_http_request(
&self,
endpoint_name: &str,
request: &HttpRequest,
) -> Result<Box<dyn ErasedSerialize>, ControllerError>;
fn new_parser(
&self,
endpoint_name: &str,
input_stream: &InputCollectionHandle,
config: &Value,
) -> Result<Box<dyn Parser>, ControllerError>;
}Expand description
Trait that represents a specific data format.
This is a factory trait that creates parsers for a specific data format.
Required Methods§
Sourcefn config_from_http_request(
&self,
endpoint_name: &str,
request: &HttpRequest,
) -> Result<Box<dyn ErasedSerialize>, ControllerError>
fn config_from_http_request( &self, endpoint_name: &str, request: &HttpRequest, ) -> Result<Box<dyn ErasedSerialize>, ControllerError>
Extract parser configuration from an HTTP request.
Returns the extracted configuration cast to the ErasedSerialize trait
object (to keep this trait object-safe).
§Discussion
We could rely on the serde_urlencoded crate to deserialize the config
from the HTTP request, which is what most implementations will do
internally; however allowing the implementation to override this
method enables additional flexibility. For example, an
implementation may use Content-Type and other request headers, set
HTTP-specific defaults for config fields, etc.
Sourcefn new_parser(
&self,
endpoint_name: &str,
input_stream: &InputCollectionHandle,
config: &Value,
) -> Result<Box<dyn Parser>, ControllerError>
fn new_parser( &self, endpoint_name: &str, input_stream: &InputCollectionHandle, config: &Value, ) -> Result<Box<dyn Parser>, ControllerError>
Create a new parser for the format.
§Arguments
-
input_stream- Input stream of the circuit to push parsed data to. -
config- Format-specific configuration.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".