mountos_admin_sdk/compat.rs
1//! Backward-compatible aliases for the pre-1.14.0 "Pair" naming. 1.14.0
2//! renamed Pair -> Copyset (types and methods) without shipping migration
3//! aliases, a semver-breaking change in a minor release. This module
4//! restores the old names as aliases/wrapper methods so code written
5//! against <1.14.0 keeps compiling; new code should use the Copyset-named
6//! exports directly. The old names are deprecated.
7//!
8//! `type X = Y` is a genuine Rust type alias (X and Y are the same type),
9//! so this is a lossless, zero-cost compatibility layer for the type-only
10//! renames below (`Pair`, `PairState`, `DrainPairStorageResponse`). It does
11//! NOT cover field-level renames on structs that were never themselves
12//! renamed (`BlockVolume::copyset_id`, `UpdateConfigResult`'s
13//! `*copyset*`/`active_copyset_count_*` fields,
14//! `VolumeBlockPlacementConfig::copyset_ids`,
15//! `VolumeBlockPlacementResizeResult`'s `copyset_count_*`/`copysets_*`
16//! fields): Rust has no field-alias mechanism, so restoring those would
17//! need a hand-written parallel struct with its own Deserialize impl.
18//! Neither is done here; no known Rust consumer of this SDK exists in the
19//! mountOS suite. `UpdateVolumePairConfigRequest` is the one request type
20//! below that had its own field renamed, so it is a distinct struct
21//! translated at the call site rather than a plain alias.
22//!
23//! Hand-written, not touched by `make gen`.
24
25use crate::{
26 Copyset, CopysetState, DrainCopysetStorageResponse, Error, StoragesService,
27 UpdateVolumeCopysetConfigRequest, VolumeBlockPlacementConfig, VolumeBlockPlacementResizeResult,
28 VolumesService,
29};
30
31/// Deprecated: use [`CopysetState`] instead.
32pub type PairState = CopysetState;
33
34/// Deprecated: use [`Copyset`] instead.
35pub type Pair = Copyset;
36
37/// Deprecated: use [`DrainCopysetStorageResponse`] instead.
38pub type DrainPairStorageResponse = DrainCopysetStorageResponse;
39
40/// Deprecated: use [`UpdateVolumeCopysetConfigRequest`] instead.
41#[derive(Debug, Clone)]
42pub struct UpdateVolumePairConfigRequest {
43 pub target_pair_count: i32,
44}
45
46impl From<&UpdateVolumePairConfigRequest> for UpdateVolumeCopysetConfigRequest {
47 fn from(req: &UpdateVolumePairConfigRequest) -> Self {
48 UpdateVolumeCopysetConfigRequest { target_copyset_count: req.target_pair_count }
49 }
50}
51
52impl StoragesService {
53 /// Deprecated: use [`StoragesService::list_copysets`] instead.
54 pub async fn list_pairs(
55 &self,
56 storage_id: i64,
57 state: Option<&str>,
58 include_retired: Option<bool>,
59 ) -> Result<Vec<Pair>, Error> {
60 self.list_copysets(storage_id, state, include_retired).await
61 }
62
63 /// Deprecated: use [`StoragesService::get_copyset_status`] instead.
64 pub async fn get_pair_status(&self, storage_id: i64, pair_id: &str) -> Result<Pair, Error> {
65 self.get_copyset_status(storage_id, pair_id).await
66 }
67
68 /// Deprecated: use [`StoragesService::drain_copyset`] instead.
69 pub async fn drain_pair(&self, storage_id: i64, pair_id: &str) -> Result<DrainPairStorageResponse, Error> {
70 self.drain_copyset(storage_id, pair_id).await
71 }
72}
73
74impl VolumesService {
75 /// Deprecated: use [`VolumesService::get_copyset_config`] instead.
76 pub async fn get_pair_config(&self, volume_id: i64) -> Result<VolumeBlockPlacementConfig, Error> {
77 self.get_copyset_config(volume_id).await
78 }
79
80 /// Deprecated: use [`VolumesService::update_copyset_config`] instead.
81 pub async fn update_pair_config(
82 &self,
83 volume_id: i64,
84 req: &UpdateVolumePairConfigRequest,
85 ) -> Result<VolumeBlockPlacementResizeResult, Error> {
86 self.update_copyset_config(volume_id, &UpdateVolumeCopysetConfigRequest::from(req)).await
87 }
88}