0.7.27 +Refactor
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
|
||||
/// Application-facing normalized pool listing DTO.
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
pub struct KbPoolListingDto {
|
||||
pub struct PoolListingDto {
|
||||
/// Optional numeric primary key.
|
||||
pub id: std::option::Option<i64>,
|
||||
/// Related DEX id.
|
||||
@@ -14,7 +14,7 @@ pub struct KbPoolListingDto {
|
||||
/// Optional related pair id.
|
||||
pub pair_id: std::option::Option<i64>,
|
||||
/// Discovery source family.
|
||||
pub source_kind: crate::KbObservationSourceKind,
|
||||
pub source_kind: crate::ObservationSourceKind,
|
||||
/// Optional source endpoint logical name.
|
||||
pub source_endpoint_name: std::option::Option<std::string::String>,
|
||||
/// Detection timestamp.
|
||||
@@ -29,13 +29,13 @@ pub struct KbPoolListingDto {
|
||||
pub updated_at: chrono::DateTime<chrono::Utc>,
|
||||
}
|
||||
|
||||
impl KbPoolListingDto {
|
||||
impl PoolListingDto {
|
||||
/// Creates a new pool listing DTO.
|
||||
pub fn new(
|
||||
dex_id: i64,
|
||||
pool_id: i64,
|
||||
pair_id: std::option::Option<i64>,
|
||||
source_kind: crate::KbObservationSourceKind,
|
||||
source_kind: crate::ObservationSourceKind,
|
||||
source_endpoint_name: std::option::Option<std::string::String>,
|
||||
initial_base_reserve: std::option::Option<f64>,
|
||||
initial_quote_reserve: std::option::Option<f64>,
|
||||
@@ -58,11 +58,11 @@ impl KbPoolListingDto {
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<crate::KbPoolListingEntity> for KbPoolListingDto {
|
||||
type Error = crate::KbError;
|
||||
impl TryFrom<crate::PoolListingEntity> for PoolListingDto {
|
||||
type Error = crate::Error;
|
||||
|
||||
fn try_from(entity: crate::KbPoolListingEntity) -> Result<Self, Self::Error> {
|
||||
let source_kind_result = crate::KbObservationSourceKind::from_i16(entity.source_kind);
|
||||
fn try_from(entity: crate::PoolListingEntity) -> Result<Self, Self::Error> {
|
||||
let source_kind_result = crate::ObservationSourceKind::from_i16(entity.source_kind);
|
||||
let source_kind = match source_kind_result {
|
||||
Ok(source_kind) => source_kind,
|
||||
Err(error) => return Err(error),
|
||||
@@ -71,7 +71,7 @@ impl TryFrom<crate::KbPoolListingEntity> for KbPoolListingDto {
|
||||
let detected_at = match detected_at_result {
|
||||
Ok(detected_at) => detected_at.with_timezone(&chrono::Utc),
|
||||
Err(error) => {
|
||||
return Err(crate::KbError::Db(format!(
|
||||
return Err(crate::Error::Db(format!(
|
||||
"cannot parse pool_listing detected_at '{}': {}",
|
||||
entity.detected_at, error
|
||||
)));
|
||||
@@ -81,7 +81,7 @@ impl TryFrom<crate::KbPoolListingEntity> for KbPoolListingDto {
|
||||
let updated_at = match updated_at_result {
|
||||
Ok(updated_at) => updated_at.with_timezone(&chrono::Utc),
|
||||
Err(error) => {
|
||||
return Err(crate::KbError::Db(format!(
|
||||
return Err(crate::Error::Db(format!(
|
||||
"cannot parse pool_listing updated_at '{}': {}",
|
||||
entity.updated_at, error
|
||||
)));
|
||||
|
||||
Reference in New Issue
Block a user