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`,
13//! `VolumeBlockPlacementConfig::copyset_ids`,
14//! `VolumeBlockPlacementResizeResult`'s `copyset_count_*`/`copysets_*`
15//! fields): Rust has no field-alias mechanism, so restoring those would
16//! need a hand-written parallel struct with its own Deserialize impl.
17//! Neither is done here; no known Rust consumer of this SDK exists in the
18//! mountOS suite. `UpdateVolumePairConfigRequest` is the one request type
19//! below that had its own field renamed, so it is a distinct struct
20//! translated at the call site rather than a plain alias.
21//!
22//! Hand-written, not touched by `make gen`.
23
24use crate::{
25 Copyset, CopysetState, DrainCopysetStorageResponse, Error, StoragesService,
26 UpdateVolumeCopysetConfigRequest, VolumeBlockPlacementConfig, VolumeBlockPlacementResizeResult,
27 VolumesService,
28};
29
30/// Deprecated: use [`CopysetState`] instead.
31pub type PairState = CopysetState;
32
33/// Deprecated: use [`Copyset`] instead.
34pub type Pair = Copyset;
35
36/// Deprecated: use [`DrainCopysetStorageResponse`] instead.
37pub type DrainPairStorageResponse = DrainCopysetStorageResponse;
38
39/// Deprecated: use [`UpdateVolumeCopysetConfigRequest`] instead.
40#[derive(Debug, Clone)]
41pub struct UpdateVolumePairConfigRequest {
42 pub target_pair_count: i32,
43}
44
45impl From<&UpdateVolumePairConfigRequest> for UpdateVolumeCopysetConfigRequest {
46 fn from(req: &UpdateVolumePairConfigRequest) -> Self {
47 UpdateVolumeCopysetConfigRequest { target_copyset_count: req.target_pair_count }
48 }
49}
50
51impl StoragesService {
52 /// Deprecated: use [`StoragesService::list_copysets`] instead.
53 pub async fn list_pairs(
54 &self,
55 storage_id: i64,
56 state: Option<&str>,
57 include_retired: Option<bool>,
58 ) -> Result<Vec<Pair>, Error> {
59 self.list_copysets(storage_id, state, include_retired).await
60 }
61
62 /// Deprecated: use [`StoragesService::get_copyset_status`] instead.
63 pub async fn get_pair_status(&self, storage_id: i64, pair_id: &str) -> Result<Pair, Error> {
64 self.get_copyset_status(storage_id, pair_id).await
65 }
66
67 /// Deprecated: use [`StoragesService::drain_copyset`] instead.
68 pub async fn drain_pair(&self, storage_id: i64, pair_id: &str) -> Result<DrainPairStorageResponse, Error> {
69 self.drain_copyset(storage_id, pair_id).await
70 }
71}
72
73impl VolumesService {
74 /// Deprecated: use [`VolumesService::get_copyset_config`] instead.
75 pub async fn get_pair_config(&self, volume_id: i64) -> Result<VolumeBlockPlacementConfig, Error> {
76 self.get_copyset_config(volume_id).await
77 }
78
79 /// Deprecated: use [`VolumesService::update_copyset_config`] instead.
80 pub async fn update_pair_config(
81 &self,
82 volume_id: i64,
83 req: &UpdateVolumePairConfigRequest,
84 ) -> Result<VolumeBlockPlacementResizeResult, Error> {
85 self.update_copyset_config(volume_id, &UpdateVolumeCopysetConfigRequest::from(req)).await
86 }
87}