pub struct ChainStreamClient {
pub server_url: String,
pub stream_url: String,
pub stream: StreamApi,
pub debug: bool,
/* private fields */
}Expand description
Main ChainStream client that provides access to all SDK functionality
§Example
use chainstream_sdk::ChainStreamClient;
#[tokio::main]
async fn main() {
let client = ChainStreamClient::new("your-access-token", None);
// Use the stream API for real-time data
client.stream.connect().await.unwrap();
// Subscribe to token candles
let unsub = client.stream.subscribe_token_candles(
"sol",
"So11111111111111111111111111111111111111112",
"1s",
|candle| {
println!("Candle: {:?}", candle);
},
None,
).await.unwrap();
}Fields§
§server_url: StringBase URL for REST API
stream_url: StringWebSocket URL for Stream API
stream: StreamApiStream API for real-time data subscriptions
debug: boolDebug mode flag
Implementations§
Source§impl ChainStreamClient
impl ChainStreamClient
Sourcepub fn new(
access_token: &str,
options: Option<ChainStreamClientOptions>,
) -> Self
pub fn new( access_token: &str, options: Option<ChainStreamClientOptions>, ) -> Self
Create a new ChainStreamClient with an access token
§Arguments
access_token- The access token for authenticationoptions- Optional configuration options
§Example
use chainstream_sdk::{ChainStreamClient, ChainStreamClientOptions};
let client = ChainStreamClient::new("your-access-token", None);
// Or with custom options
let client = ChainStreamClient::new("your-access-token", Some(ChainStreamClientOptions {
stream_url: Some("wss://custom-url.com/ws".to_string()),
..Default::default()
}));Sourcepub fn new_with_token_provider<T: TokenProvider>(
token_provider: &T,
options: Option<ChainStreamClientOptions>,
) -> Self
pub fn new_with_token_provider<T: TokenProvider>( token_provider: &T, options: Option<ChainStreamClientOptions>, ) -> Self
Create a new ChainStreamClient with a token provider for dynamic token refresh
§Arguments
token_provider- A token provider that can refresh tokensoptions- Optional configuration options
Sourcepub fn get_access_token(&self) -> &str
pub fn get_access_token(&self) -> &str
Get the current access token
Auto Trait Implementations§
impl Freeze for ChainStreamClient
impl !RefUnwindSafe for ChainStreamClient
impl Send for ChainStreamClient
impl Sync for ChainStreamClient
impl Unpin for ChainStreamClient
impl !UnwindSafe for ChainStreamClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more