diff --git a/services/identity/src/grpc_services/shared.rs b/services/identity/src/grpc_services/shared.rs --- a/services/identity/src/grpc_services/shared.rs +++ b/services/identity/src/grpc_services/shared.rs @@ -4,13 +4,7 @@ use crate::constants::{request_metadata, MIN_SUPPORTED_NATIVE_VERSION}; -#[derive(Clone, Debug)] -pub struct PlatformMetadata { - pub device_type: String, - pub code_version: u64, - pub state_version: Option, - pub major_desktop_version: Option, -} +pub use grpc_clients::identity::shared::PlatformMetadata; pub fn version_interceptor(req: Request<()>) -> Result, Status> { trace!("Intercepting request to check version: {:?}", req); diff --git a/shared/grpc_clients/src/identity/shared.rs b/shared/grpc_clients/src/identity/shared.rs --- a/shared/grpc_clients/src/identity/shared.rs +++ b/shared/grpc_clients/src/identity/shared.rs @@ -4,6 +4,14 @@ Request, Status, }; +#[derive(Clone, Debug)] +pub struct PlatformMetadata { + pub device_type: String, + pub code_version: u64, + pub state_version: Option, + pub major_desktop_version: Option, +} + pub struct CodeVersionLayer { pub(crate) code_version: u64, pub(crate) device_type: String, @@ -11,6 +19,29 @@ pub(crate) major_desktop_version: Option, } +impl PlatformMetadata { + /// Simplified constructor for basic params only + fn new(code_version: u64, device_type: impl Into) -> Self { + Self { + code_version, + device_type: device_type.into(), + state_version: None, + major_desktop_version: None, + } + } +} + +impl From for CodeVersionLayer { + fn from(value: PlatformMetadata) -> Self { + Self { + code_version: value.code_version, + device_type: value.device_type, + state_version: value.state_version, + major_desktop_version: value.major_desktop_version, + } + } +} + impl Interceptor for CodeVersionLayer { fn call(&mut self, mut request: Request<()>) -> Result, Status> { let metadata = request.metadata_mut();