pub struct HyperStackClient<T> { /* private fields */ }Implementations§
Source§impl<T> HyperStackClient<T>
impl<T> HyperStackClient<T>
Sourcepub fn new(url: impl Into<String>, view: impl Into<String>) -> Self
pub fn new(url: impl Into<String>, view: impl Into<String>) -> Self
Examples found in repository?
examples/flip/flip_demo.rs (line 68)
63async fn main() -> anyhow::Result<()> {
64 let url = std::env::args().nth(1).unwrap_or_else(|| "ws://127.0.0.1:8080".to_string());
65
66 let view = std::env::var("VIEW").unwrap_or_else(|_| "SettlementGame/kv".to_string());
67
68 let mut client = HyperStackClient::<SettlementGame>::new(url, &view);
69
70 if let Ok(key) = std::env::var("KEY") {
71 client = client.with_key(key);
72 }
73
74 let store = client.connect().await?;
75
76 println!("connected, watching {}...\n", view);
77
78 let mut updates = store.subscribe();
79
80 loop {
81 tokio::select! {
82 Ok((key, game)) = updates.recv() => {
83 println!("\n=== Game {} ===", key);
84 println!("{}", serde_json::to_string_pretty(&game).unwrap_or_default());
85 }
86 _ = sleep(Duration::from_secs(30)) => {
87 println!("No updates for 30s...");
88 }
89 }
90 }
91}More examples
examples/pump/token_trades.rs (line 33)
29async fn main() -> anyhow::Result<()> {
30 let url = std::env::args().nth(1).unwrap_or_else(|| "ws://127.0.0.1:8080".to_string());
31 let mint = std::env::var("KEY").expect("KEY env var required (token mint address)");
32
33 let client = HyperStackClient::<PumpToken>::new(url, "PumpToken/kv")
34 .with_key(&mint);
35
36 let store = client.connect().await?;
37
38 println!("watching trades for token {}...\n", mint);
39
40 let mut updates = store.subscribe();
41 let mut trade_history: VecDeque<TradeInfo> = VecDeque::with_capacity(100);
42
43 loop {
44 tokio::select! {
45 Ok((_key, token)) = updates.recv() => {
46 if let Some(trade) = token.last_trade {
47 trade_history.push_back(trade.clone());
48 if trade_history.len() > 100 {
49 trade_history.pop_front();
50 }
51
52 println!("[{}] {} | {}... | {:.4} SOL (total: {} trades)",
53 Utc::now().format("%H:%M:%S"),
54 trade.direction,
55 &trade.wallet[..8],
56 trade.amount_sol,
57 trade_history.len());
58 }
59 }
60 _ = sleep(Duration::from_secs(60)) => {
61 println!("No trades for 60s...");
62 }
63 }
64 }
65}examples/pump/new_launches.rs (line 24)
21async fn main() -> anyhow::Result<()> {
22 let url = std::env::args().nth(1).unwrap_or_else(|| "ws://127.0.0.1:8080".to_string());
23
24 let client = HyperStackClient::<PumpToken>::new(url, "PumpToken/list");
25
26 let store = client.connect().await?;
27
28 println!("watching for new pump.fun token launches...\n");
29
30 let mut updates = store.subscribe();
31
32 loop {
33 tokio::select! {
34 Ok((mint, token)) = updates.recv() => {
35 if token.name.is_some() || token.symbol.is_some() {
36 println!("\n[{}] new token launch", Utc::now().format("%Y-%m-%d %H:%M:%S UTC"));
37 println!("mint: {}", mint);
38 if let Some(name) = &token.name {
39 println!("name: {}", name);
40 }
41 if let Some(symbol) = &token.symbol {
42 println!("symbol: {}", symbol);
43 }
44 if let Some(creator) = &token.creator {
45 println!("creator: {}", creator);
46 }
47 if let Some(sol) = token.virtual_sol_reserves {
48 println!("initial liquidity: {:.4} SOL", sol as f64 / 1e9);
49 }
50 }
51 }
52 _ = sleep(Duration::from_secs(60)) => {
53 println!("No new launches for 60s...");
54 }
55 }
56 }
57}Sourcepub fn with_key(self, key: impl Into<String>) -> Self
pub fn with_key(self, key: impl Into<String>) -> Self
Examples found in repository?
examples/flip/flip_demo.rs (line 71)
63async fn main() -> anyhow::Result<()> {
64 let url = std::env::args().nth(1).unwrap_or_else(|| "ws://127.0.0.1:8080".to_string());
65
66 let view = std::env::var("VIEW").unwrap_or_else(|_| "SettlementGame/kv".to_string());
67
68 let mut client = HyperStackClient::<SettlementGame>::new(url, &view);
69
70 if let Ok(key) = std::env::var("KEY") {
71 client = client.with_key(key);
72 }
73
74 let store = client.connect().await?;
75
76 println!("connected, watching {}...\n", view);
77
78 let mut updates = store.subscribe();
79
80 loop {
81 tokio::select! {
82 Ok((key, game)) = updates.recv() => {
83 println!("\n=== Game {} ===", key);
84 println!("{}", serde_json::to_string_pretty(&game).unwrap_or_default());
85 }
86 _ = sleep(Duration::from_secs(30)) => {
87 println!("No updates for 30s...");
88 }
89 }
90 }
91}More examples
examples/pump/token_trades.rs (line 34)
29async fn main() -> anyhow::Result<()> {
30 let url = std::env::args().nth(1).unwrap_or_else(|| "ws://127.0.0.1:8080".to_string());
31 let mint = std::env::var("KEY").expect("KEY env var required (token mint address)");
32
33 let client = HyperStackClient::<PumpToken>::new(url, "PumpToken/kv")
34 .with_key(&mint);
35
36 let store = client.connect().await?;
37
38 println!("watching trades for token {}...\n", mint);
39
40 let mut updates = store.subscribe();
41 let mut trade_history: VecDeque<TradeInfo> = VecDeque::with_capacity(100);
42
43 loop {
44 tokio::select! {
45 Ok((_key, token)) = updates.recv() => {
46 if let Some(trade) = token.last_trade {
47 trade_history.push_back(trade.clone());
48 if trade_history.len() > 100 {
49 trade_history.pop_front();
50 }
51
52 println!("[{}] {} | {}... | {:.4} SOL (total: {} trades)",
53 Utc::now().format("%H:%M:%S"),
54 trade.direction,
55 &trade.wallet[..8],
56 trade.amount_sol,
57 trade_history.len());
58 }
59 }
60 _ = sleep(Duration::from_secs(60)) => {
61 println!("No trades for 60s...");
62 }
63 }
64 }
65}Sourcepub async fn connect(self) -> Result<EntityStore<T>>
pub async fn connect(self) -> Result<EntityStore<T>>
Examples found in repository?
examples/flip/flip_demo.rs (line 74)
63async fn main() -> anyhow::Result<()> {
64 let url = std::env::args().nth(1).unwrap_or_else(|| "ws://127.0.0.1:8080".to_string());
65
66 let view = std::env::var("VIEW").unwrap_or_else(|_| "SettlementGame/kv".to_string());
67
68 let mut client = HyperStackClient::<SettlementGame>::new(url, &view);
69
70 if let Ok(key) = std::env::var("KEY") {
71 client = client.with_key(key);
72 }
73
74 let store = client.connect().await?;
75
76 println!("connected, watching {}...\n", view);
77
78 let mut updates = store.subscribe();
79
80 loop {
81 tokio::select! {
82 Ok((key, game)) = updates.recv() => {
83 println!("\n=== Game {} ===", key);
84 println!("{}", serde_json::to_string_pretty(&game).unwrap_or_default());
85 }
86 _ = sleep(Duration::from_secs(30)) => {
87 println!("No updates for 30s...");
88 }
89 }
90 }
91}More examples
examples/pump/token_trades.rs (line 36)
29async fn main() -> anyhow::Result<()> {
30 let url = std::env::args().nth(1).unwrap_or_else(|| "ws://127.0.0.1:8080".to_string());
31 let mint = std::env::var("KEY").expect("KEY env var required (token mint address)");
32
33 let client = HyperStackClient::<PumpToken>::new(url, "PumpToken/kv")
34 .with_key(&mint);
35
36 let store = client.connect().await?;
37
38 println!("watching trades for token {}...\n", mint);
39
40 let mut updates = store.subscribe();
41 let mut trade_history: VecDeque<TradeInfo> = VecDeque::with_capacity(100);
42
43 loop {
44 tokio::select! {
45 Ok((_key, token)) = updates.recv() => {
46 if let Some(trade) = token.last_trade {
47 trade_history.push_back(trade.clone());
48 if trade_history.len() > 100 {
49 trade_history.pop_front();
50 }
51
52 println!("[{}] {} | {}... | {:.4} SOL (total: {} trades)",
53 Utc::now().format("%H:%M:%S"),
54 trade.direction,
55 &trade.wallet[..8],
56 trade.amount_sol,
57 trade_history.len());
58 }
59 }
60 _ = sleep(Duration::from_secs(60)) => {
61 println!("No trades for 60s...");
62 }
63 }
64 }
65}examples/pump/new_launches.rs (line 26)
21async fn main() -> anyhow::Result<()> {
22 let url = std::env::args().nth(1).unwrap_or_else(|| "ws://127.0.0.1:8080".to_string());
23
24 let client = HyperStackClient::<PumpToken>::new(url, "PumpToken/list");
25
26 let store = client.connect().await?;
27
28 println!("watching for new pump.fun token launches...\n");
29
30 let mut updates = store.subscribe();
31
32 loop {
33 tokio::select! {
34 Ok((mint, token)) = updates.recv() => {
35 if token.name.is_some() || token.symbol.is_some() {
36 println!("\n[{}] new token launch", Utc::now().format("%Y-%m-%d %H:%M:%S UTC"));
37 println!("mint: {}", mint);
38 if let Some(name) = &token.name {
39 println!("name: {}", name);
40 }
41 if let Some(symbol) = &token.symbol {
42 println!("symbol: {}", symbol);
43 }
44 if let Some(creator) = &token.creator {
45 println!("creator: {}", creator);
46 }
47 if let Some(sol) = token.virtual_sol_reserves {
48 println!("initial liquidity: {:.4} SOL", sol as f64 / 1e9);
49 }
50 }
51 }
52 _ = sleep(Duration::from_secs(60)) => {
53 println!("No new launches for 60s...");
54 }
55 }
56 }
57}Auto Trait Implementations§
impl<T> Freeze for HyperStackClient<T>
impl<T> RefUnwindSafe for HyperStackClient<T>where
T: RefUnwindSafe,
impl<T> Send for HyperStackClient<T>where
T: Send,
impl<T> Sync for HyperStackClient<T>where
T: Sync,
impl<T> Unpin for HyperStackClient<T>where
T: Unpin,
impl<T> UnwindSafe for HyperStackClient<T>where
T: UnwindSafe,
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