Răsfoiți Sursa

feat(pyth-lazer-protocol): add pub error type (#2287)

Tejas Badadare 10 luni în urmă
părinte
comite
6c1ffdd92a

+ 1 - 1
lazer/Cargo.lock

@@ -3698,7 +3698,7 @@ dependencies = [
 
 [[package]]
 name = "pyth-lazer-protocol"
-version = "0.3.0"
+version = "0.3.1"
 dependencies = [
  "alloy-primitives",
  "anyhow",

+ 1 - 1
lazer/sdk/rust/protocol/Cargo.toml

@@ -1,6 +1,6 @@
 [package]
 name = "pyth-lazer-protocol"
-version = "0.3.0"
+version = "0.3.1"
 edition = "2021"
 description = "Pyth Lazer SDK - protocol types."
 license = "Apache-2.0"

+ 16 - 0
lazer/sdk/rust/protocol/src/publisher.rs

@@ -4,6 +4,7 @@
 
 use {
     super::router::{Price, PriceFeedId, TimestampUs},
+    derive_more::derive::From,
     serde::{Deserialize, Serialize},
 };
 
@@ -32,6 +33,21 @@ pub struct PriceFeedData {
     pub best_ask_price: Option<Price>,
 }
 
+/// A response sent from the server to the publisher client.
+/// Currently only serde errors are reported back to the client.
+#[derive(Debug, Clone, Serialize, Deserialize, From)]
+#[serde(tag = "type")]
+#[serde(rename_all = "camelCase")]
+pub enum PublisherResponse {
+    UpdateDeserializationError(UpdateDeserializationErrorResponse),
+}
+/// Sent to the publisher if the binary data could not be parsed
+#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct UpdateDeserializationErrorResponse {
+    pub error: String,
+}
+
 #[test]
 fn price_feed_data_serde() {
     let data = [

+ 2 - 1
lazer/sdk/rust/protocol/src/subscription.rs

@@ -67,7 +67,8 @@ pub struct SubscriptionErrorResponse {
     pub error: String,
 }
 
-/// Sent from the server if an error occured while serving data for an existing subscription.
+/// Sent from the server if an internal error occured while serving data for an existing subscription,
+/// or a client request sent a bad request.
 #[derive(Debug, Clone, Serialize, Deserialize)]
 #[serde(rename_all = "camelCase")]
 pub struct ErrorResponse {