Skip to content

Commit 2cd41a3

Browse files
style: improve code formatting and fix example documentation
Co-Authored-By: Tejas Badadare <[email protected]>
1 parent 9964432 commit 2cd41a3

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

lazer/sdk/rust/sdk/examples/subscribe_price_feeds.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@ use pyth_lazer_sdk::LazerClient;
99
#[tokio::main]
1010
async fn main() -> anyhow::Result<()> {
1111
// Create and start the client
12-
let mut client = LazerClient::new(
13-
"wss://hermes.pyth.network",
14-
"YOUR_ACCESS_TOKEN".to_string(),
15-
)?;
12+
let mut client =
13+
LazerClient::new("wss://hermes.pyth.network", "YOUR_ACCESS_TOKEN".to_string())?;
1614
let mut stream = client.start().await?;
1715

1816
// Create subscription request

lazer/sdk/rust/sdk/src/lib.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ pub enum BinaryResponse {
3939
///
4040
/// #[tokio::main]
4141
/// async fn main() -> anyhow::Result<()> {
42-
/// let (mut client, mut stream) = LazerConsumerClient::start("wss://endpoint").await?;
42+
/// let mut client = LazerClient::new("wss://endpoint", "YOUR_ACCESS_TOKEN".to_string())?;
43+
/// let mut stream = client.start().await?;
4344
///
4445
/// // Subscribe to price feeds
4546
/// client.subscribe(Request::Subscribe(SubscribeRequest {
@@ -57,12 +58,14 @@ pub enum BinaryResponse {
5758
pub struct LazerClient {
5859
endpoint: Url,
5960
access_token: String,
60-
ws_sender: Option<futures_util::stream::SplitSink<
61-
tokio_tungstenite::WebSocketStream<
62-
tokio_tungstenite::MaybeTlsStream<tokio::net::TcpStream>,
61+
ws_sender: Option<
62+
futures_util::stream::SplitSink<
63+
tokio_tungstenite::WebSocketStream<
64+
tokio_tungstenite::MaybeTlsStream<tokio::net::TcpStream>,
65+
>,
66+
Message,
6367
>,
64-
Message,
65-
>>,
68+
>,
6669
}
6770

6871
impl LazerClient {
@@ -89,8 +92,9 @@ impl LazerClient {
8992
/// Returns a stream of responses from the server
9093
pub async fn start(&mut self) -> Result<impl futures_util::Stream<Item = Result<Response>>> {
9194
let url = self.endpoint.clone();
92-
let mut request = tokio_tungstenite::tungstenite::client::IntoClientRequest::into_client_request(url)?;
93-
95+
let mut request =
96+
tokio_tungstenite::tungstenite::client::IntoClientRequest::into_client_request(url)?;
97+
9498
request.headers_mut().insert(
9599
"Authorization",
96100
format!("Bearer {}", self.access_token).parse().unwrap(),

0 commit comments

Comments
 (0)