-
Notifications
You must be signed in to change notification settings - Fork 209
Open
Description
Current rpc definition allows adding types to item:
#[subscription(name = "subscribeStorage" => "override", item = Vec<Hash>)]
async fn subscribe_storage(&self, keys: Option<Vec<StorageKey>>) -> SubscriptionResult;
but this isn't enforced at the server-side:
async fn subscribe_storage(
&self,
pending: PendingSubscriptionSink,
_keys: Option<Vec<ExampleStorageKey>>,
) -> SubscriptionResult {
let sink = pending.accept().await?;
let json = serde_json::value::to_raw_value(&vec![[0.123123; 32]])?; // compiles ok (can send anything)
sink.send(json).await?;
Ok(())
}
Can this be enforced with SubscriptionSink by adding a generic param?
On the serverimplementation side, it would be:
async fn subscribe_storage(
&self,
pending: PendingSubscriptionSink<Hash>,
_keys: Option<Vec<ExampleStorageKey>>,
) -> SubscriptionResult {
let sink = pending.accept().await?;
// ...
sink.send(not_hash).await?; // <-- compiler type error
sink.send(some_hash).await?; // <-- compiler ok
Ok(())
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels