Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Remove Clone trait from ExtnMessage #484

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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 core/launcher/src/launcher_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl LauncherState {
let extn_message_response: Result<ExtnMessage, RippleError> =
extn_client.request(Config::LauncherConfig).await;
if let Ok(message) = extn_message_response {
if let Some(config) = message.payload.extract() {
if let Some(config) = message.extract() {
return Ok(LauncherState {
config,
view_state: ViewState::default(),
Expand Down
15 changes: 7 additions & 8 deletions core/launcher/src/manager/app_launcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ impl AppLauncher {
.send_extn_request(DeviceInfoRequest::AvailableMemory)
.await
{
if let Some(ExtnResponse::Value(v)) = msg.payload.extract() {
if let Some(ExtnResponse::Value(v)) = msg.extract() {
if let Some(memory) = v.as_u64() {
return Ok(memory);
}
Expand Down Expand Up @@ -582,7 +582,7 @@ impl AppLauncher {
return Err(AppError::NotSupported);
}
match resp {
Ok(response) => match response.payload.extract::<AppResponse>() {
Ok(response) => match response.extract::<AppResponse>() {
Some(Ok(AppManagerResponse::Session(SessionResponse::Completed(val)))) => {
sessionid = val.session_id;
debug!("session id : {:?} ", sessionid);
Expand Down Expand Up @@ -634,12 +634,11 @@ impl AppLauncher {
return Err(AppError::NotSupported);
}

let callsign =
if let Some(ExtnResponse::String(callsign)) = response.unwrap().payload.extract() {
callsign
} else {
return Err(AppError::NotSupported);
};
let callsign = if let Some(ExtnResponse::String(callsign)) = response.unwrap().extract() {
callsign
} else {
return Err(AppError::NotSupported);
};

let intent = request
.intent
Expand Down
2 changes: 1 addition & 1 deletion core/main/src/firebolt/firebolt_gateway.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ impl FireboltGateway {
}
HandleRpc { request } => self.handle(request, None).await,
HandleRpcForExtn { msg } => {
if let Some(request) = msg.payload.clone().extract() {
if let Some(request) = msg.extract() {
self.handle(request, Some(msg)).await
} else {
error!("Not a valid RPC Request {:?}", msg);
Expand Down
6 changes: 2 additions & 4 deletions core/main/src/firebolt/handlers/accessory_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl AccessoryServer for AccessoryImpl {
.await
{
if let Some(RemoteAccessoryResponse::RemoteAccessoryListResponse(value)) =
response.payload.extract()
response.extract()
{
return Ok(value);
}
Expand All @@ -94,9 +94,7 @@ impl AccessoryServer for AccessoryImpl {
.send_extn_request(RemoteAccessoryRequest::Pair(pair_request))
.await
{
if let Some(RemoteAccessoryResponse::AccessoryPairResponse(v)) =
response.payload.extract()
{
if let Some(RemoteAccessoryResponse::AccessoryPairResponse(v)) = response.extract() {
return Ok(v);
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/main/src/firebolt/handlers/account_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ impl AccountServer for AccountImpl {
})
.await
{
if let Some(ExtnResponse::String(s)) = resp.payload.extract() {
if let Some(ExtnResponse::String(s)) = resp.extract() {
return Ok(s);
}
}
Expand Down
4 changes: 2 additions & 2 deletions core/main/src/firebolt/handlers/advertising_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ impl AdvertisingServer for AdvertisingImpl {

if let Ok(payload) = resp {
if let Some(AdvertisingResponse::AdIdObject(obj)) =
payload.payload.extract::<AdvertisingResponse>()
payload.extract::<AdvertisingResponse>()
{
let ad_id = AdvertisingId {
ifa: obj.ifa,
Expand Down Expand Up @@ -383,7 +383,7 @@ impl AdvertisingServer for AdvertisingImpl {
.send_extn_request(advertising_request)
.await
{
Ok(message) => match message.payload.extract() {
Ok(message) => match message.extract() {
Some(advertising_resp) => match advertising_resp {
AdvertisingResponse::AdConfig(resp) => resp,
_ => {
Expand Down
2 changes: 1 addition & 1 deletion core/main/src/firebolt/handlers/authentication_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ impl AuthenticationImpl {
}
};
match resp {
Ok(payload) => match payload.payload.extract().unwrap() {
Ok(payload) => match payload.extract().unwrap() {
ExtnResponse::Token(t) => Ok(TokenResult {
value: t.value,
expires: t.expires,
Expand Down
28 changes: 13 additions & 15 deletions core/main/src/firebolt/handlers/device_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,7 @@ pub async fn get_uid(state: &PlatformState, app_id: String) -> RpcResult<String>
})
.await
{
if let Some(ExtnResponse::String(enc_device_id)) =
resp.payload.extract::<ExtnResponse>()
{
if let Some(ExtnResponse::String(enc_device_id)) = resp.extract::<ExtnResponse>() {
return Ok(enc_device_id);
}
}
Expand All @@ -222,7 +220,7 @@ pub async fn get_ll_mac_addr(state: PlatformState) -> RpcResult<String> {
.send_extn_request(DeviceInfoRequest::MacAddress)
.await;
match resp {
Ok(response) => match response.payload.extract().unwrap() {
Ok(response) => match response.extract().unwrap() {
ExtnResponse::String(value) => Ok(filter_mac(value)),
_ => Err(jsonrpsee::core::Error::Custom(String::from(
"MAC Info error response TBD",
Expand Down Expand Up @@ -256,7 +254,7 @@ impl DeviceImpl {
.await;

match resp {
Ok(dab_payload) => match dab_payload.payload.extract().unwrap() {
Ok(dab_payload) => match dab_payload.extract().unwrap() {
DeviceResponse::FirmwareInfo(value) => Ok(value),
_ => Err(jsonrpsee::core::Error::Custom(String::from(
"Firmware Info error response TBD",
Expand Down Expand Up @@ -342,7 +340,7 @@ impl DeviceServer for DeviceImpl {
.send_extn_request(DeviceInfoRequest::Model)
.await
{
if let Some(ExtnResponse::String(v)) = response.payload.extract() {
if let Some(ExtnResponse::String(v)) = response.extract() {
if let Some(f) = self
.state
.get_device_manifest()
Expand All @@ -364,7 +362,7 @@ impl DeviceServer for DeviceImpl {
.send_extn_request(DeviceInfoRequest::Model)
.await
{
if let Some(ExtnResponse::String(v)) = response.payload.extract() {
if let Some(ExtnResponse::String(v)) = response.extract() {
return Ok(v);
}
}
Expand All @@ -379,7 +377,7 @@ impl DeviceServer for DeviceImpl {
.await;

match resp {
Ok(payload) => match payload.payload.extract().unwrap() {
Ok(payload) => match payload.extract().unwrap() {
DeviceResponse::HdcpSupportResponse(value) => Ok(value),
_ => Err(jsonrpsee::core::Error::Custom(String::from(
"Hdcp capabilities error response TBD",
Expand Down Expand Up @@ -433,7 +431,7 @@ impl DeviceServer for DeviceImpl {
.await;

match resp {
Ok(response) => match response.payload.extract().unwrap() {
Ok(response) => match response.extract().unwrap() {
DeviceResponse::HdrResponse(value) => Ok(value),
_ => Err(jsonrpsee::core::Error::Custom(String::from(
"Hdr capabilities error response TBD",
Expand Down Expand Up @@ -487,7 +485,7 @@ impl DeviceServer for DeviceImpl {
)
.await
{
if let Some(DeviceResponse::ScreenResolutionResponse(value)) = resp.payload.extract() {
if let Some(DeviceResponse::ScreenResolutionResponse(value)) = resp.extract() {
return Ok(value);
}
}
Expand Down Expand Up @@ -539,7 +537,7 @@ impl DeviceServer for DeviceImpl {
)
.await
{
if let Some(DeviceResponse::VideoResolutionResponse(value)) = resp.payload.extract() {
if let Some(DeviceResponse::VideoResolutionResponse(value)) = resp.extract() {
return Ok(value);
}
}
Expand Down Expand Up @@ -589,7 +587,7 @@ impl DeviceServer for DeviceImpl {
.send_extn_request(DeviceInfoRequest::Make)
.await
{
if let Some(ExtnResponse::String(v)) = response.payload.extract() {
if let Some(ExtnResponse::String(v)) = response.extract() {
return Ok(v);
}
}
Expand All @@ -608,7 +606,7 @@ impl DeviceServer for DeviceImpl {
.await;

match resp {
Ok(response) => match response.payload.extract().unwrap() {
Ok(response) => match response.extract().unwrap() {
DeviceResponse::AudioProfileResponse(audio) => Ok(audio),
_ => Err(jsonrpsee::core::Error::Custom(String::from(
"Audio error response TBD",
Expand Down Expand Up @@ -665,7 +663,7 @@ impl DeviceServer for DeviceImpl {
.await;

match resp {
Ok(response) => match response.payload.extract().unwrap() {
Ok(response) => match response.extract().unwrap() {
ExtnResponse::NetworkResponse(value) => Ok(value),
_ => Err(jsonrpsee::core::Error::Custom(String::from(
"Network Status error response TBD",
Expand Down Expand Up @@ -726,7 +724,7 @@ impl DeviceServer for DeviceImpl {
.send_extn_request(AccountSessionRequest::Provision(provision_request))
.await;
match resp {
Ok(payload) => match payload.payload.extract().unwrap() {
Ok(payload) => match payload.extract().unwrap() {
ExtnResponse::None(()) => Ok(()),
_ => Err(rpc_err("Provision Status error response TBD")),
},
Expand Down
5 changes: 2 additions & 3 deletions core/main/src/firebolt/handlers/discovery_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,6 @@ impl DiscoveryImpl {
let def_lang = match result {
Ok(extn_message) => {
match extn_message
.payload
.extract()
.unwrap_or_else(|| ExtnResponse::String("en".to_owned()))
{
Expand Down Expand Up @@ -478,7 +477,7 @@ impl DiscoveryServer for DiscoveryImpl {
.send_extn_request(AccountLinkRequest::Watched(request))
.await
{
if let Some(ExtnResponse::Boolean(v)) = response.payload.extract() {
if let Some(ExtnResponse::Boolean(v)) = response.extract() {
return Ok(v);
}
}
Expand Down Expand Up @@ -511,7 +510,7 @@ impl DiscoveryServer for DiscoveryImpl {
.send_extn_request(AccountLinkRequest::Watched(request))
.await
{
if let Some(ExtnResponse::Boolean(v)) = response.payload.extract() {
if let Some(ExtnResponse::Boolean(v)) = response.extract() {
return Ok(v);
}
}
Expand Down
4 changes: 2 additions & 2 deletions core/main/src/firebolt/handlers/localization_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ impl LocalizationServer for LocalizationImpl {
"timezone_set: error response TBD",
)));
}
if let Some(ExtnResponse::AvailableTimezones(timezones)) = resp.unwrap().payload.extract() {
if let Some(ExtnResponse::AvailableTimezones(timezones)) = resp.unwrap().extract() {
if !timezones.contains(&set_request.value) {
error!(
"timezone_set: Unsupported timezone: tz={}",
Expand Down Expand Up @@ -546,7 +546,7 @@ impl LocalizationServer for LocalizationImpl {
.send_extn_request(DeviceInfoRequest::GetTimezone)
.await
{
if let Some(ExtnResponse::String(v)) = response.payload.extract() {
if let Some(ExtnResponse::String(v)) = response.extract() {
return Ok(v);
}
}
Expand Down
12 changes: 6 additions & 6 deletions core/main/src/firebolt/handlers/privacy_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -513,8 +513,8 @@ impl PrivacyImpl {
let payload = PrivacySettingsStoreRequest::GetPrivacySettings(property);
let response = platform_state.get_client().send_extn_request(payload).await;
if let Ok(extn_msg) = response {
match extn_msg.payload {
ExtnPayload::Response(res) => match res {
match extn_msg.get_extn_payload() {
Ok(ExtnPayload::Response(res)) => match res {
ExtnResponse::Boolean(val) => RpcResult::Ok(val),
_ => RpcResult::Err(jsonrpsee::core::Error::Custom(
"Unable to fetch".to_owned(),
Expand All @@ -537,7 +537,7 @@ impl PrivacyImpl {
dist_session,
});
if let Ok(resp) = platform_state.get_client().send_extn_request(request).await {
if let Some(ExtnResponse::Boolean(b)) = resp.payload.extract() {
if let Some(ExtnResponse::Boolean(b)) = resp.extract() {
return Ok(b);
}
}
Expand Down Expand Up @@ -570,8 +570,8 @@ impl PrivacyImpl {
let payload = PrivacySettingsStoreRequest::SetPrivacySettings(property, value);
let response = platform_state.get_client().send_extn_request(payload).await;
if let Ok(extn_msg) = response {
match extn_msg.payload {
ExtnPayload::Response(res) => match res {
match extn_msg.get_extn_payload() {
Ok(ExtnPayload::Response(res)) => match res {
ExtnResponse::None(_) => RpcResult::Ok(()),
_ => RpcResult::Err(jsonrpsee::core::Error::Custom(
"Unable to fetch".to_owned(),
Expand Down Expand Up @@ -1032,7 +1032,7 @@ impl PrivacyServer for PrivacyImpl {
if let Some(dist_session) = self.state.session_state.get_account_session() {
let request = PrivacyCloudRequest::GetProperties(dist_session);
if let Ok(resp) = self.state.get_client().send_extn_request(request).await {
if let Some(b) = resp.payload.extract() {
if let Some(b) = resp.extract() {
return Ok(b);
}
}
Expand Down
4 changes: 2 additions & 2 deletions core/main/src/firebolt/handlers/profile_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl ProfileServer for ProfileImpl {
.send_extn_request(pin_request)
.await
{
if let Some(ExtnResponse::PinChallenge(v)) = response.payload.extract() {
if let Some(ExtnResponse::PinChallenge(v)) = response.extract() {
return Ok(v.granted.map_or(false, |inner| inner));
}
}
Expand All @@ -99,7 +99,7 @@ impl ProfileServer for ProfileImpl {
.send_extn_request(pin_request)
.await
{
if let Some(ExtnResponse::PinChallenge(v)) = response.payload.extract() {
if let Some(ExtnResponse::PinChallenge(v)) = response.extract() {
return Ok(v.granted.map_or(false, |inner| inner));
}
}
Expand Down
8 changes: 4 additions & 4 deletions core/main/src/firebolt/handlers/secure_storage_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ impl SecureStorageImpl {
.await
{
Ok(response) => {
if let Some(ExtnResponse::SecureStorage(_r)) = response.payload.extract() {
if let Some(ExtnResponse::SecureStorage(_r)) = response.extract() {
Ok(())
} else {
Err(get_err_msg(RippleError::ExtnError))
Expand All @@ -139,7 +139,7 @@ impl SecureStorageImpl {
.await
{
Ok(response) => {
if let Some(ExtnResponse::SecureStorage(_r)) = response.payload.extract() {
if let Some(ExtnResponse::SecureStorage(_r)) = response.extract() {
Ok(())
} else {
Err(get_err_msg(RippleError::ExtnError))
Expand All @@ -160,7 +160,7 @@ impl SecureStorageImpl {
.await
{
Ok(response) => {
if let Some(ExtnResponse::SecureStorage(_r)) = response.payload.extract() {
if let Some(ExtnResponse::SecureStorage(_r)) = response.extract() {
Ok(())
} else {
Err(get_err_msg(RippleError::ExtnError))
Expand Down Expand Up @@ -190,7 +190,7 @@ impl SecureStorageServer for SecureStorageImpl {
{
Ok(response) => {
if let Some(ExtnResponse::SecureStorage(SecureStorageResponse::Get(v))) =
response.payload.extract()
response.extract()
{
Ok(v.value)
} else {
Expand Down
4 changes: 2 additions & 2 deletions core/main/src/firebolt/handlers/voice_guidance_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ pub async fn voice_guidance_settings_enabled(state: &PlatformState) -> RpcResult
.await;
match resp {
Ok(value) => {
if let Some(ExtnResponse::Boolean(v)) = value.payload.extract() {
if let Some(ExtnResponse::Boolean(v)) = value.extract() {
Ok(v)
} else {
Err(jsonrpsee::core::Error::Custom(String::from(
Expand All @@ -148,7 +148,7 @@ pub async fn voice_guidance_settings_speed(state: &PlatformState) -> RpcResult<f
.await;
match resp {
Ok(value) => {
if let Some(ExtnResponse::Float(v)) = value.payload.extract() {
if let Some(ExtnResponse::Float(v)) = value.extract() {
Ok(v)
} else {
Err(jsonrpsee::core::Error::Custom(String::from(
Expand Down
Loading
Loading