Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lazer/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lazer/sdk/rust/protocol/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pyth-lazer-protocol"
version = "0.3.3"
version = "0.4.0"
edition = "2021"
description = "Pyth Lazer SDK - protocol types."
license = "Apache-2.0"
Expand Down
11 changes: 5 additions & 6 deletions lazer/sdk/rust/protocol/src/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ pub enum JsonBinaryEncoding {

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub enum Channel {
RealTime,
FixedRate(FixedRate),
}

Expand All @@ -173,8 +172,10 @@ impl Serialize for Channel {
S: serde::Serializer,
{
match self {
Channel::RealTime => serializer.serialize_str("real_time"),
Channel::FixedRate(fixed_rate) => {
if *fixed_rate == FixedRate::MIN {
return serializer.serialize_str("real_time");
}
serializer.serialize_str(&format!("fixed_rate@{}ms", fixed_rate.value_ms()))
}
}
Expand All @@ -184,16 +185,14 @@ impl Serialize for Channel {
mod channel_ids {
use super::ChannelId;

pub const REAL_TIME: ChannelId = ChannelId(1);
pub const FIXED_RATE_1: ChannelId = ChannelId(1);
pub const FIXED_RATE_50: ChannelId = ChannelId(2);
pub const FIXED_RATE_200: ChannelId = ChannelId(3);
pub const FIXED_RATE_1: ChannelId = ChannelId(4);
}

impl Channel {
pub fn id(&self) -> ChannelId {
match self {
Channel::RealTime => channel_ids::REAL_TIME,
Channel::FixedRate(fixed_rate) => match fixed_rate.value_ms() {
1 => channel_ids::FIXED_RATE_1,
50 => channel_ids::FIXED_RATE_50,
Expand All @@ -213,7 +212,7 @@ fn id_supports_all_fixed_rates() {

fn parse_channel(value: &str) -> Option<Channel> {
if value == "real_time" {
Some(Channel::RealTime)
Some(Channel::FixedRate(FixedRate::MIN))
} else if let Some(rest) = value.strip_prefix("fixed_rate@") {
let ms_value = rest.strip_suffix("ms")?;
Some(Channel::FixedRate(FixedRate::from_ms(
Expand Down
Loading