1use crate::*;
2use cyfs_base::*;
3
4use std::fmt;
5use std::str::FromStr;
6
7#[derive(Clone, Debug)]
8pub struct RootStateOutputRequestCommon {
9 pub dec_id: Option<ObjectId>,
11
12 pub target_dec_id: Option<ObjectId>,
14
15 pub target: Option<ObjectId>,
17
18 pub flags: u32,
19}
20
21impl RootStateOutputRequestCommon {
22 pub fn new() -> Self {
23 Self {
24 dec_id: None,
25 target_dec_id: None,
26 target: None,
27 flags: 0,
28 }
29 }
30}
31
32impl fmt::Display for RootStateOutputRequestCommon {
33 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
34 if let Some(dec_id) = &self.dec_id {
35 write!(f, "dec_id: {}", dec_id)?;
36 }
37 if let Some(dec_id) = &self.target_dec_id {
38 write!(f, ", target_dec_id: {}", dec_id)?;
39 }
40
41 if let Some(target) = &self.target {
42 write!(f, ", target: {}", target)?;
43 }
44
45 write!(f, ", flags: {}", self.flags)?;
46
47 Ok(())
48 }
49}
50
51#[derive(Clone, Debug, Eq, PartialEq)]
53pub enum RootStateRootType {
54 Global,
55 Dec,
56}
57
58impl ToString for RootStateRootType {
59 fn to_string(&self) -> String {
60 (match *self {
61 Self::Global => "global",
62 Self::Dec => "dec",
63 })
64 .to_owned()
65 }
66}
67
68impl FromStr for RootStateRootType {
69 type Err = BuckyError;
70
71 fn from_str(value: &str) -> Result<Self, Self::Err> {
72 let ret = match value {
73 "global" => Self::Global,
74 "dec" => Self::Dec,
75
76 v @ _ => {
77 let msg = format!("unknown root_type value: {}", v);
78 error!("{}", msg);
79
80 return Err(BuckyError::new(BuckyErrorCode::InvalidData, msg));
81 }
82 };
83
84 Ok(ret)
85 }
86}
87
88#[derive(Clone)]
89pub struct RootStateGetCurrentRootOutputRequest {
90 pub common: RootStateOutputRequestCommon,
91
92 pub root_type: RootStateRootType,
93}
94
95impl RootStateGetCurrentRootOutputRequest {
96 pub fn new_global() -> Self {
97 Self {
98 common: RootStateOutputRequestCommon::new(),
99 root_type: RootStateRootType::Global,
100 }
101 }
102 pub fn new_dec() -> Self {
103 Self {
104 common: RootStateOutputRequestCommon::new(),
105 root_type: RootStateRootType::Dec,
106 }
107 }
108}
109
110#[derive(Debug)]
111pub struct RootStateGetCurrentRootOutputResponse {
112 pub root: ObjectId,
113 pub revision: u64,
114 pub dec_root: Option<ObjectId>,
115}
116
117#[derive(Clone)]
118pub struct RootStateOpEnvAccess {
119 pub path: String,
120 pub access: AccessPermissions,
121}
122
123impl fmt::Display for RootStateOpEnvAccess {
124 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
125 write!(f, "path: {}, access: {}", self.path, self.access.as_str())
126 }
127}
128impl fmt::Debug for RootStateOpEnvAccess {
129 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
130 fmt::Display::fmt(&self, f)
131 }
132}
133
134impl RootStateOpEnvAccess {
135 pub fn new(path: impl Into<String>, access: AccessPermissions) -> Self {
136 Self {
137 path: path.into(),
138 access,
139 }
140 }
141}
142
143#[derive(Clone, Debug)]
145pub struct RootStateCreateOpEnvOutputRequest {
146 pub common: RootStateOutputRequestCommon,
147
148 pub op_env_type: ObjectMapOpEnvType,
149 pub access: Option<RootStateOpEnvAccess>,
150}
151
152impl RootStateCreateOpEnvOutputRequest {
153 pub fn new(op_env_type: ObjectMapOpEnvType) -> Self {
154 Self {
155 common: RootStateOutputRequestCommon::new(),
156 op_env_type,
157 access: None,
158 }
159 }
160
161 pub fn new_with_access(op_env_type: ObjectMapOpEnvType, access: RootStateOpEnvAccess) -> Self {
162 Self {
163 common: RootStateOutputRequestCommon::new(),
164 op_env_type,
165 access: Some(access),
166 }
167 }
168}
169
170pub struct RootStateCreateOpEnvOutputResponse {
171 pub sid: u64,
172}
173
174#[derive(Clone, Debug)]
175pub struct OpEnvOutputRequestCommon {
176 pub dec_id: Option<ObjectId>,
178
179 pub target_dec_id: Option<ObjectId>,
181
182 pub target: Option<ObjectId>,
184
185 pub flags: u32,
186
187 pub sid: u64,
189}
190
191impl OpEnvOutputRequestCommon {
192 pub fn new_empty() -> Self {
193 Self {
194 dec_id: None,
195 target_dec_id: None,
196 target: None,
197 flags: 0,
198 sid: 0,
199 }
200 }
201}
202
203impl fmt::Display for OpEnvOutputRequestCommon {
204 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
205 write!(f, "sid: {}", self.sid)?;
206
207 if let Some(dec_id) = &self.dec_id {
208 write!(f, ", dec_id: {}", dec_id)?;
209 }
210 if let Some(target_dec_id) = &self.target_dec_id {
211 write!(f, ", target_dec_id: {}", target_dec_id)?;
212 }
213
214 if let Some(target) = &self.target {
215 write!(f, ", target: {}", target)?;
216 }
217
218 write!(f, ", flags: {}", self.flags)?;
219
220 Ok(())
221 }
222}
223
224pub struct OpEnvNoParamOutputRequest {
225 pub common: OpEnvOutputRequestCommon,
226}
227
228impl OpEnvNoParamOutputRequest {
229 pub fn new() -> Self {
230 Self {
231 common: OpEnvOutputRequestCommon::new_empty(),
232 }
233 }
234}
235
236pub struct OpEnvLoadOutputRequest {
239 pub common: OpEnvOutputRequestCommon,
240
241 pub target: ObjectId,
242 pub inner_path: Option<String>,
243}
244
245impl OpEnvLoadOutputRequest {
246 pub fn new(target: ObjectId) -> Self {
247 Self {
248 common: OpEnvOutputRequestCommon::new_empty(),
249 target,
250 inner_path: None,
251 }
252 }
253
254 pub fn new_with_inner_path(target: ObjectId, inner_path: impl Into<String>) -> Self {
255 Self {
256 common: OpEnvOutputRequestCommon::new_empty(),
257 target,
258 inner_path: Some(inner_path.into()),
259 }
260 }
261}
262
263pub struct OpEnvLoadByPathOutputRequest {
265 pub common: OpEnvOutputRequestCommon,
266
267 pub path: String,
268}
269
270impl OpEnvLoadByPathOutputRequest {
271 pub fn new(path: String) -> Self {
272 Self {
273 common: OpEnvOutputRequestCommon::new_empty(),
274 path,
275 }
276 }
277}
278
279#[derive(Clone, Debug, Eq, PartialEq)]
280pub enum ObjectMapField {
281 Default,
283 None,
284 Specific(ObjectId),
285}
286
287impl Default for ObjectMapField {
288 fn default() -> Self {
289 Self::Default
290 }
291}
292
293impl ToString for ObjectMapField {
294 fn to_string(&self) -> String {
295 match self {
296 Self::Default => "default".to_owned(),
297 Self::None => "none".to_owned(),
298 Self::Specific(id) => id.to_string(),
299 }
300 }
301}
302
303impl FromStr for ObjectMapField {
304 type Err = BuckyError;
305
306 fn from_str(value: &str) -> BuckyResult<Self> {
307 match value {
308 "default" => Ok(Self::Default),
309 "none" => Ok(Self::None),
310 _ => Ok(Self::Specific(ObjectId::from_str(value)?)),
311 }
312 }
313}
314
315impl From<&Option<ObjectId>> for ObjectMapField {
316 fn from(id: &Option<ObjectId>) -> Self {
317 id.as_ref()
318 .map_or(Self::None, |id| Self::Specific(id.clone()))
319 }
320}
321
322impl From<&ObjectId> for ObjectMapField {
323 fn from(id: &ObjectId) -> Self {
324 Self::Specific(id.clone())
325 }
326}
327
328pub struct OpEnvCreateNewOutputRequest {
330 pub common: OpEnvOutputRequestCommon,
331
332 pub path: Option<String>,
333 pub key: Option<String>,
334 pub content_type: ObjectMapSimpleContentType,
335
336 pub owner: Option<ObjectMapField>,
338 pub dec: Option<ObjectMapField>,
339}
340
341impl OpEnvCreateNewOutputRequest {
342 pub fn new(content_type: ObjectMapSimpleContentType) -> Self {
343 Self {
344 common: OpEnvOutputRequestCommon::new_empty(),
345 path: None,
346 key: None,
347 content_type,
348 owner: None,
349 dec: None,
350 }
351 }
352
353 pub fn new_with_full_path(
354 full_path: impl Into<String>,
355 content_type: ObjectMapSimpleContentType,
356 ) -> Self {
357 let full_path = full_path.into();
358 assert!(full_path.len() > 0);
359
360 Self {
361 common: OpEnvOutputRequestCommon::new_empty(),
362 path: None,
363 key: Some(full_path),
364 content_type,
365 owner: None,
366 dec: None,
367 }
368 }
369
370 pub fn new_with_path_and_key(
371 path: impl Into<String>,
372 key: impl Into<String>,
373 content_type: ObjectMapSimpleContentType,
374 ) -> Self {
375 let path = path.into();
376 let key = key.into();
377 assert!(OpEnvPathHelper::check_valid(&path, &key));
378
379 Self {
380 common: OpEnvOutputRequestCommon::new_empty(),
381 path: Some(path),
382 key: Some(key),
383 content_type,
384 owner: None,
385 dec: None,
386 }
387 }
388}
389
390pub struct OpEnvLockOutputRequest {
392 pub common: OpEnvOutputRequestCommon,
393
394 pub path_list: Vec<String>,
395 pub duration_in_millsecs: u64,
396 pub try_lock: bool,
397}
398
399impl OpEnvLockOutputRequest {
400 pub fn new(path_list: Vec<String>, duration_in_millsecs: u64) -> Self {
401 Self {
402 common: OpEnvOutputRequestCommon::new_empty(),
403 path_list,
404 duration_in_millsecs,
405 try_lock: false,
406 }
407 }
408
409 pub fn new_try(path_list: Vec<String>, duration_in_millsecs: u64) -> Self {
410 Self {
411 common: OpEnvOutputRequestCommon::new_empty(),
412 path_list,
413 duration_in_millsecs,
414 try_lock: true,
415 }
416 }
417}
418
419pub type OpEnvGetCurrentRootOutputRequest = OpEnvNoParamOutputRequest;
421pub type OpEnvGetCurrentRootOutputResponse = OpEnvCommitOutputResponse;
422
423#[derive(Clone, Debug)]
424pub enum OpEnvCommitOpType {
425 Commit,
426 Update,
427}
428
429impl OpEnvCommitOpType {
430 pub fn as_str(&self) -> &str {
431 match self {
432 Self::Commit => "commit",
433 Self::Update => "update",
434 }
435 }
436}
437
438impl ToString for OpEnvCommitOpType {
439 fn to_string(&self) -> String {
440 self.as_str().to_owned()
441 }
442}
443
444impl FromStr for OpEnvCommitOpType {
445 type Err = BuckyError;
446
447 fn from_str(value: &str) -> Result<Self, Self::Err> {
448 let ret = match value {
449 "commit" => Self::Commit,
450 "update" => Self::Update,
451
452 v @ _ => {
453 let msg = format!("unknown OpEnvCommitOpType value: {}", v);
454 error!("{}", msg);
455
456 return Err(BuckyError::new(BuckyErrorCode::InvalidData, msg));
457 }
458 };
459
460 Ok(ret)
461 }
462}
463
464impl Default for OpEnvCommitOpType {
465 fn default() -> Self {
466 Self::Commit
467 }
468}
469
470pub struct OpEnvCommitOutputRequest {
472 pub common: OpEnvOutputRequestCommon,
473 pub op_type: Option<OpEnvCommitOpType>,
474}
475
476impl OpEnvCommitOutputRequest {
477 pub fn new() -> Self {
478 Self {
479 common: OpEnvOutputRequestCommon::new_empty(),
480 op_type: None,
481 }
482 }
483
484 pub fn new_update() -> Self {
485 Self {
486 common: OpEnvOutputRequestCommon::new_empty(),
487 op_type: Some(OpEnvCommitOpType::Update),
488 }
489 }
490}
491
492pub struct OpEnvCommitOutputResponse {
493 pub root: ObjectId,
494 pub revision: u64,
495
496 pub dec_root: ObjectId,
497}
498
499pub type OpEnvAbortOutputRequest = OpEnvNoParamOutputRequest;
501
502pub struct OpEnvPathHelper {}
503
504impl OpEnvPathHelper {
505 pub fn check_key_valid(key: &str) -> bool {
506 if key.is_empty() || key.find("/").is_some() {
507 return false;
508 }
509
510 true
511 }
512
513 pub fn check_valid(path: &str, key: &str) -> bool {
514 if path.is_empty() || !Self::check_key_valid(key) {
515 return false;
516 }
517
518 true
519 }
520
521 pub fn join(path: &str, key: &str) -> String {
522 if path.ends_with("/") {
523 format!("{}{}", path, key)
524 } else {
525 format!("{}/{}", path, key)
526 }
527 }
528}
529
530pub struct OpEnvMetadataOutputRequest {
532 pub common: OpEnvOutputRequestCommon,
533 pub path: Option<String>,
534}
535
536impl OpEnvMetadataOutputRequest {
537 pub fn new(path: Option<String>) -> Self {
538 Self {
539 common: OpEnvOutputRequestCommon::new_empty(),
540 path,
541 }
542 }
543}
544
545#[derive(Debug)]
546pub struct OpEnvMetadataOutputResponse {
547 pub content_mode: ObjectMapContentMode,
548 pub content_type: ObjectMapSimpleContentType,
549 pub count: u64,
550 pub size: u64,
551 pub depth: u8,
552}
553
554#[derive(Clone)]
556pub struct OpEnvGetByKeyOutputRequest {
557 pub common: OpEnvOutputRequestCommon,
558
559 pub path: Option<String>,
560 pub key: String,
561}
562
563impl fmt::Display for OpEnvGetByKeyOutputRequest {
564 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
565 write!(f, "common: {}", self.common)?;
566
567 if let Some(path) = &self.path {
568 write!(f, ", path: {}", path)?;
569 }
570
571 write!(f, ", key: {}", self.key)
572 }
573}
574
575impl OpEnvGetByKeyOutputRequest {
576 pub fn new_path_and_key(path: impl Into<String>, key: impl Into<String>) -> Self {
577 let path = path.into();
578 let key = key.into();
579
580 assert!(OpEnvPathHelper::check_valid(&path, &key));
581
582 let req = OpEnvGetByKeyOutputRequest {
583 common: OpEnvOutputRequestCommon::new_empty(),
584 path: Some(path),
585 key,
586 };
587
588 req
589 }
590
591 pub fn new_full_path(full_path: impl Into<String>) -> Self {
592 let full_path = full_path.into();
593 assert!(full_path.len() > 0);
594
595 let req = OpEnvGetByKeyOutputRequest {
596 common: OpEnvOutputRequestCommon::new_empty(),
597 path: None,
598 key: full_path,
599 };
600
601 req
602 }
603
604 pub fn new_key(key: impl Into<String>) -> Self {
605 let key = key.into();
606 assert!(OpEnvPathHelper::check_key_valid(&key));
607
608 let req = OpEnvGetByKeyOutputRequest {
609 common: OpEnvOutputRequestCommon::new_empty(),
610 path: None,
611 key,
612 };
613
614 req
615 }
616}
617
618#[derive(Debug)]
619pub struct OpEnvGetByKeyOutputResponse {
620 pub value: Option<ObjectId>,
621}
622
623#[derive(Clone)]
625pub struct OpEnvInsertWithKeyOutputRequest {
626 pub common: OpEnvOutputRequestCommon,
627
628 pub path: Option<String>,
629 pub key: String,
630 pub value: ObjectId,
631}
632
633impl OpEnvInsertWithKeyOutputRequest {
634 pub fn new_path_and_key_value(
635 path: impl Into<String>,
636 key: impl Into<String>,
637 value: ObjectId,
638 ) -> Self {
639 let path = path.into();
640 let key = key.into();
641 assert!(OpEnvPathHelper::check_valid(&path, &key));
642
643 let req = Self {
644 common: OpEnvOutputRequestCommon::new_empty(),
645 path: Some(path),
646 key,
647 value,
648 };
649
650 req
651 }
652
653 pub fn new_full_path_and_value(full_path: impl Into<String>, value: ObjectId) -> Self {
654 let full_path = full_path.into();
655 assert!(full_path.len() > 0);
656
657 let req = Self {
658 common: OpEnvOutputRequestCommon::new_empty(),
659 path: None,
660 key: full_path,
661 value,
662 };
663
664 req
665 }
666
667 pub fn new_key_value(key: impl Into<String>, value: ObjectId) -> Self {
668 let key = key.into();
669 assert!(OpEnvPathHelper::check_key_valid(&key));
670
671 let req = Self {
672 common: OpEnvOutputRequestCommon::new_empty(),
673 path: None,
674 key,
675 value,
676 };
677
678 req
679 }
680}
681
682#[derive(Clone)]
684pub struct OpEnvSetWithKeyOutputRequest {
685 pub common: OpEnvOutputRequestCommon,
686
687 pub path: Option<String>,
688 pub key: String,
689 pub value: ObjectId,
690 pub prev_value: Option<ObjectId>,
691 pub auto_insert: bool,
692}
693
694impl OpEnvSetWithKeyOutputRequest {
695 pub fn new_path_and_key_value(
696 path: impl Into<String>,
697 key: impl Into<String>,
698 value: ObjectId,
699 prev_value: Option<ObjectId>,
700 auto_insert: bool,
701 ) -> Self {
702 let path = path.into();
703 let key = key.into();
704 assert!(OpEnvPathHelper::check_valid(&path, &key));
705
706 let req = Self {
707 common: OpEnvOutputRequestCommon::new_empty(),
708 path: Some(path),
709 key,
710 value,
711 prev_value,
712 auto_insert,
713 };
714
715 req
716 }
717
718 pub fn new_full_path_and_value(
719 full_path: impl Into<String>,
720 value: ObjectId,
721 prev_value: Option<ObjectId>,
722 auto_insert: bool,
723 ) -> Self {
724 let full_path = full_path.into();
725 assert!(full_path.len() > 0);
726
727 let req = Self {
728 common: OpEnvOutputRequestCommon::new_empty(),
729 path: None,
730 key: full_path,
731 value,
732 prev_value,
733 auto_insert,
734 };
735
736 req
737 }
738
739 pub fn new_key_value(
740 key: impl Into<String>,
741 value: ObjectId,
742 prev_value: Option<ObjectId>,
743 auto_insert: bool,
744 ) -> Self {
745 let key = key.into();
746 assert!(OpEnvPathHelper::check_key_valid(&key));
747
748 let req = Self {
749 common: OpEnvOutputRequestCommon::new_empty(),
750 path: None,
751 key,
752 value,
753 prev_value,
754 auto_insert,
755 };
756
757 req
758 }
759}
760
761#[derive(Clone)]
762pub struct OpEnvSetWithKeyOutputResponse {
763 pub prev_value: Option<ObjectId>,
764}
765
766#[derive(Clone)]
768pub struct OpEnvRemoveWithKeyOutputRequest {
769 pub common: OpEnvOutputRequestCommon,
770
771 pub path: Option<String>,
772 pub key: String,
773 pub prev_value: Option<ObjectId>,
774}
775
776impl OpEnvRemoveWithKeyOutputRequest {
777 pub fn new_path_and_key(
778 path: impl Into<String>,
779 key: impl Into<String>,
780 prev_value: Option<ObjectId>,
781 ) -> Self {
782 let path = path.into();
783 let key = key.into();
784 assert!(OpEnvPathHelper::check_valid(&path, &key));
785
786 let req = Self {
787 common: OpEnvOutputRequestCommon::new_empty(),
788 path: Some(path),
789 key,
790 prev_value,
791 };
792
793 req
794 }
795
796 pub fn new_full_path(full_path: impl Into<String>, prev_value: Option<ObjectId>) -> Self {
797 let full_path = full_path.into();
798 assert!(full_path.len() > 0);
799
800 let req = OpEnvRemoveWithKeyOutputRequest {
801 common: OpEnvOutputRequestCommon::new_empty(),
802 path: None,
803 key: full_path,
804 prev_value,
805 };
806
807 req
808 }
809
810 pub fn new_key(key: impl Into<String>, prev_value: Option<ObjectId>) -> Self {
811 let key = key.into();
812 assert!(key.len() > 0);
813
814 let req = OpEnvRemoveWithKeyOutputRequest {
815 common: OpEnvOutputRequestCommon::new_empty(),
816 path: None,
817 key,
818 prev_value,
819 };
820
821 req
822 }
823}
824
825#[derive(Clone)]
826pub struct OpEnvRemoveWithKeyOutputResponse {
827 pub value: Option<ObjectId>,
828}
829
830pub struct OpEnvSetOutputRequest {
832 pub common: OpEnvOutputRequestCommon,
833
834 pub path: Option<String>,
835 pub value: ObjectId,
836}
837
838impl OpEnvSetOutputRequest {
839 pub fn new_path(path: impl Into<String>, value: ObjectId) -> Self {
840 let path = path.into();
841 assert!(path.len() > 0);
842
843 let req = OpEnvSetOutputRequest {
844 common: OpEnvOutputRequestCommon::new_empty(),
845 path: Some(path),
846 value,
847 };
848
849 req
850 }
851
852 pub fn new(value: ObjectId) -> Self {
853 let req = OpEnvContainsOutputRequest {
854 common: OpEnvOutputRequestCommon::new_empty(),
855 path: None,
856 value,
857 };
858
859 req
860 }
861}
862
863pub struct OpEnvSetOutputResponse {
864 pub result: bool,
865}
866
867pub type OpEnvContainsOutputRequest = OpEnvSetOutputRequest;
869pub type OpEnvContainsOutputResponse = OpEnvSetOutputResponse;
870
871pub type OpEnvInsertOutputRequest = OpEnvSetOutputRequest;
873pub type OpEnvInsertOutputResponse = OpEnvSetOutputResponse;
874
875pub type OpEnvRemoveOutputRequest = OpEnvSetOutputRequest;
877pub type OpEnvRemoveOutputResponse = OpEnvSetOutputResponse;
878
879pub struct OpEnvNextOutputRequest {
883 pub common: OpEnvOutputRequestCommon,
884
885 pub step: u32,
887}
888
889impl OpEnvNextOutputRequest {
890 pub fn new(step: u32) -> Self {
891 Self {
892 common: OpEnvOutputRequestCommon::new_empty(),
893 step,
894 }
895 }
896}
897
898pub struct OpEnvNextOutputResponse {
899 pub list: Vec<ObjectMapContentItem>,
900}
901
902pub type OpEnvResetOutputRequest = OpEnvNoParamOutputRequest;
904
905pub struct OpEnvListOutputRequest {
907 pub common: OpEnvOutputRequestCommon,
908
909 pub path: Option<String>,
911}
912
913impl OpEnvListOutputRequest {
914 pub fn new() -> Self {
915 Self {
916 common: OpEnvOutputRequestCommon::new_empty(),
917 path: None,
918 }
919 }
920
921 pub fn new_path(path: impl Into<String>) -> Self {
922 Self {
923 common: OpEnvOutputRequestCommon::new_empty(),
924 path: Some(path.into()),
925 }
926 }
927}
928
929pub type OpEnvListOutputResponse = OpEnvNextOutputResponse;
930
931#[derive(Clone)]
936pub struct RootStateAccessorGetObjectByPathOutputRequest {
937 pub common: RootStateOutputRequestCommon,
938
939 pub inner_path: String,
940}
941
942impl fmt::Display for RootStateAccessorGetObjectByPathOutputRequest {
943 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
944 write!(f, "common: {}", self.common)?;
945 write!(f, ", inner_path: {}", self.inner_path)
946 }
947}
948
949impl RootStateAccessorGetObjectByPathOutputRequest {
950 pub fn new(inner_path: impl Into<String>) -> Self {
951 Self {
952 common: RootStateOutputRequestCommon::new(),
953 inner_path: inner_path.into(),
954 }
955 }
956}
957
958pub struct RootStateAccessorGetObjectByPathOutputResponse {
959 pub object: NONGetObjectOutputResponse,
960 pub root: ObjectId,
961 pub revision: u64,
962}
963
964impl fmt::Display for RootStateAccessorGetObjectByPathOutputResponse {
965 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
966 self.object.fmt(f)?;
967 write!(f, ", root: {}, revision: {}", self.root, self.revision)
968 }
969}
970
971pub struct RootStateAccessorListOutputRequest {
973 pub common: RootStateOutputRequestCommon,
974
975 pub inner_path: String,
976
977 pub page_index: Option<u32>,
979 pub page_size: Option<u32>,
980}
981
982impl RootStateAccessorListOutputRequest {
983 pub fn new(inner_path: impl Into<String>) -> Self {
984 Self {
985 common: RootStateOutputRequestCommon::new(),
986 inner_path: inner_path.into(),
987 page_index: None,
988 page_size: None,
989 }
990 }
991
992 pub fn new_with_page(inner_path: impl Into<String>, page_index: u32, page_size: u32) -> Self {
993 Self {
994 common: RootStateOutputRequestCommon::new(),
995 inner_path: inner_path.into(),
996 page_index: Some(page_index),
997 page_size: Some(page_size),
998 }
999 }
1000}
1001
1002impl fmt::Display for RootStateAccessorListOutputRequest {
1003 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1004 write!(f, "common: {}", self.common)?;
1005
1006 write!(
1007 f,
1008 ", inner_path={}, page_index: {:?}, page_size: {:?}",
1009 self.inner_path, self.page_index, self.page_size
1010 )
1011 }
1012}
1013
1014pub struct RootStateAccessorListOutputResponse {
1015 pub list: Vec<ObjectMapContentItem>,
1016
1017 pub root: ObjectId,
1018 pub revision: u64,
1019}