You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implement the Subscription and Subscriber components in the SDK as per the given specifications. These components will enable users to subscribe to specific NATS subjects and consume the incoming data stream.
use fuel_streams::{
conn::{Client,ConnectionResult},
stream::{Subscription},
types::Response,};#[tokio::main]asyncfnmain() -> ConnectionResult<()>{let server = Client::new("stream.fuel.network").await?;let subscriber = Subscription::new(Subject::Transactions).subscribe(&server)?;whileletSome(response) = subscriber.next().await{println!("Received transaction: {:?}", response);}Ok(())}
Tasks
Create a Subscription struct with the following methods:
Description
Implement the
Subscription
andSubscriber
components in the SDK as per the given specifications. These components will enable users to subscribe to specific NATS subjects and consume the incoming data stream.Tasks
Subscription
struct with the following methods:new(subject: Subject) -> Self
subscribe(server: &Client) -> Result<Subscriber, SubscriptionError>
Subscriber
struct with the following methods:next(&mut self) -> Option<Response>
try_next(&mut self) -> Result<Option<Response>, SubscriberError>
SubscriptionError
andSubscriberError
enums usingthiserror
Subscription
andSubscriber
methodsClient
and mock NATS serverTechnical Details
Subscriber
Filter
typeSubscription
works with differentSubject
types (e.g.,Transactions
,Blocks
)Response
type can handle different data types based on theSubject
thiserror
to create properSubscriptionError
andSubscriberError
enumsAdditional Notes
Client
and other SDK componentsDefinition of Done
The text was updated successfully, but these errors were encountered: