nautilus_infrastructure/sql/models/
general.rs

1// -------------------------------------------------------------------------------------------------
2//  Copyright (C) 2015-2025 Nautech Systems Pty Ltd. All rights reserved.
3//  https://nautechsystems.io
4//
5//  Licensed under the GNU Lesser General Public License Version 3.0 (the "License");
6//  You may not use this file except in compliance with the License.
7//  You may obtain a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html
8//
9//  Unless required by applicable law or agreed to in writing, software
10//  distributed under the License is distributed on an "AS IS" BASIS,
11//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12//  See the License for the specific language governing permissions and
13//  limitations under the License.
14// -------------------------------------------------------------------------------------------------
15
16use nautilus_model::identifiers::{ClientId, ClientOrderId};
17use sqlx::{Error, FromRow, Row, postgres::PgRow};
18
19#[derive(Debug, sqlx::FromRow)]
20pub struct GeneralRow {
21    pub id: String,
22    pub value: Vec<u8>,
23}
24
25#[derive(Debug)]
26pub struct OrderEventOrderClientIdCombination {
27    pub client_order_id: ClientOrderId,
28    pub client_id: ClientId,
29}
30
31impl<'r> FromRow<'r, PgRow> for OrderEventOrderClientIdCombination {
32    fn from_row(row: &'r PgRow) -> Result<Self, Error> {
33        let client_order_id = row
34            .try_get::<&str, _>("client_order_id")
35            .map(ClientOrderId::from)
36            .unwrap();
37        let client_id = row
38            .try_get::<&str, _>("client_id")
39            .map(ClientId::from)
40            .unwrap();
41        Ok(OrderEventOrderClientIdCombination {
42            client_order_id,
43            client_id,
44        })
45    }
46}