barter_integration/protocol/mod.rs
1use crate::SocketError;
2use futures::Stream;
3use serde::de::DeserializeOwned;
4
5/// Contains useful `WebSocket` type aliases and a default `WebSocket` implementation of a
6/// [`StreamParser`].
7pub mod websocket;
8
9/// Contains HTTP client capable of executing signed & unsigned requests, as well as an associated
10/// execution oriented HTTP request.
11pub mod http;
12
13/// `StreamParser`s are capable of parsing the input messages from a given stream protocol
14/// (eg/ WebSocket, Financial Information eXchange (FIX), etc.) and deserialising into an `Output`.
15pub trait StreamParser {
16 type Stream: Stream;
17 type Message;
18 type Error;
19
20 fn parse<Output>(
21 input: Result<Self::Message, Self::Error>,
22 ) -> Option<Result<Output, SocketError>>
23 where
24 Output: DeserializeOwned;
25}