Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "freenet-stdlib"
version = "0.1.32"
version = "0.1.33"
edition = "2021"
rust-version = "1.71.1"
publish = true
Expand Down
24 changes: 24 additions & 0 deletions rust/src/client_api/client_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,13 +278,15 @@ impl ClientRequest<'_> {
state,
related_contracts,
subscribe,
blocking_subscribe,
} => {
let related_contracts = related_contracts.into_owned();
ContractRequest::Put {
contract,
state,
related_contracts,
subscribe,
blocking_subscribe,
}
}
ContractRequest::Update { key, data } => {
Expand All @@ -295,10 +297,12 @@ impl ClientRequest<'_> {
key,
return_contract_code,
subscribe,
blocking_subscribe,
} => ContractRequest::Get {
key,
return_contract_code,
subscribe,
blocking_subscribe,
},
ContractRequest::Subscribe { key, summary } => ContractRequest::Subscribe {
key,
Expand Down Expand Up @@ -377,6 +381,10 @@ pub enum ContractRequest<'a> {
related_contracts: RelatedContracts<'a>,
/// If this flag is set then subscribe to updates for this contract.
subscribe: bool,
/// If true, the PUT response waits for the subscription to complete.
/// Only meaningful when `subscribe` is true.
#[serde(default)]
blocking_subscribe: bool,
},
/// Update an existing contract corresponding with the provided key.
Update {
Expand All @@ -393,6 +401,10 @@ pub enum ContractRequest<'a> {
return_contract_code: bool,
/// If this flag is set then subscribe to updates for this contract.
subscribe: bool,
/// If true, the GET response waits for the subscription to complete.
/// Only meaningful when `subscribe` is true.
#[serde(default)]
blocking_subscribe: bool,
},
/// Subscribe to the changes in a given contract. Implicitly starts a get operation
/// if the contract is not present yet.
Expand All @@ -411,11 +423,13 @@ impl ContractRequest<'_> {
state,
related_contracts,
subscribe,
blocking_subscribe,
} => ContractRequest::Put {
contract,
state,
related_contracts: related_contracts.into_owned(),
subscribe,
blocking_subscribe,
},
Self::Update { key, data } => ContractRequest::Update {
key,
Expand All @@ -425,10 +439,12 @@ impl ContractRequest<'_> {
key,
return_contract_code: fetch_contract,
subscribe,
blocking_subscribe,
} => ContractRequest::Get {
key,
return_contract_code: fetch_contract,
subscribe,
blocking_subscribe,
},
Self::Subscribe { key, summary } => ContractRequest::Subscribe {
key,
Expand Down Expand Up @@ -458,10 +474,12 @@ impl<'a> TryFromFbs<&FbsContractRequest<'a>> for ContractRequest<'a> {
let key = ContractInstanceId::new(key_bytes);
let fetch_contract = get.fetch_contract();
let subscribe = get.subscribe();
let blocking_subscribe = get.blocking_subscribe();
ContractRequest::Get {
key,
return_contract_code: fetch_contract,
subscribe,
blocking_subscribe,
}
}
ContractRequestType::Put => {
Expand All @@ -471,11 +489,13 @@ impl<'a> TryFromFbs<&FbsContractRequest<'a>> for ContractRequest<'a> {
let related_contracts =
RelatedContracts::try_decode_fbs(&put.related_contracts())?.into_owned();
let subscribe = put.subscribe();
let blocking_subscribe = put.blocking_subscribe();
ContractRequest::Put {
contract,
state,
related_contracts,
subscribe,
blocking_subscribe,
}
}
ContractRequestType::Update => {
Expand Down Expand Up @@ -1719,6 +1739,7 @@ mod client_request_test {
state,
related_contracts: _,
subscribe,
blocking_subscribe,
} => {
assert_eq!(
contract.to_string(),
Expand All @@ -1727,6 +1748,7 @@ mod client_request_test {
assert_eq!(contract.unwrap_v1().data.data(), &[1, 2, 3, 4, 5, 6, 7, 8]);
assert_eq!(state.to_vec(), &[1, 2, 3, 4, 5, 6, 7, 8]);
assert!(!subscribe);
assert!(!blocking_subscribe);
}
_ => panic!("wrong contract request type"),
}
Expand Down Expand Up @@ -1755,10 +1777,12 @@ mod client_request_test {
key,
return_contract_code: fetch_contract,
subscribe,
blocking_subscribe,
} => {
assert_eq!(key.encode(), EXPECTED_ENCODED_CONTRACT_ID);
assert!(!fetch_contract);
assert!(!subscribe);
assert!(!blocking_subscribe);
}
_ => panic!("wrong contract request type"),
}
Expand Down
Loading
Loading