1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
/// Object related structs and functions for Riak objects.
///
/// For more information: https://docs.basho.com/riak/kv/latest/developing/usage/creating-objects/

use errors::RiakErr;
use protobuf::Message;
use rpb::riak_kv::{RpbContent, RpbDelReq, RpbGetReq, RpbGetResp, RpbPutReq};
use utils::{FetchObjectRespPrivate, ObjectContentPrivate, ProtobufBytes};

/// `DeleteObjectReq` represents a request to delete an object from Riak
#[derive(Clone, Debug)]
pub struct DeleteObjectReq(RpbDelReq);

impl DeleteObjectReq {
    /// constructs a new `DeleteObjectReq`
    pub fn new<T: Into<Vec<u8>>>(bucket: T, key: T) -> DeleteObjectReq {
        let mut req = DeleteObjectReq(RpbDelReq::new());
        req.0.set_bucket(bucket.into());
        req.0.set_key(key.into());
        req
    }

    /// get the value of the "bucket_type" property
    pub fn get_bucket_type(&self) -> Option<Vec<u8>> {
        if self.0.has_field_type() {
            Some(self.0.get_field_type().to_vec())
        } else {
            None
        }
    }

    /// set the value of the "bucket_type" property
    pub fn set_bucket_type<T: Into<Vec<u8>>>(&mut self, bucket_type: T) {
        self.0.set_field_type(bucket_type.into());
    }

    /// get the value of the "bucket" property
    pub fn get_bucket(&self) -> Vec<u8> {
        self.0.get_bucket().to_vec()
    }

    /// set the value of the "bucket" property
    pub fn set_bucket<T: Into<Vec<u8>>>(&mut self, bucket: T) {
        self.0.set_bucket(bucket.into());
    }

    /// get the value of the "key" property
    pub fn get_key(&self) -> Vec<u8> {
        self.0.get_key().to_vec()
    }

    /// set the value of the "key" property
    pub fn set_key<T: Into<Vec<u8>>>(&mut self, key: T) {
        self.0.set_key(key.into());
    }

    /// get the value of the "dw" property
    pub fn get_dw(&self) -> Option<u32> {
        if self.0.has_dw() {
            Some(self.0.get_dw())
        } else {
            None
        }
    }

    /// set the value of the "dw" property
    pub fn set_dw(&mut self, dw: u32) {
        self.0.set_dw(dw);
    }

    /// get the value of the "pr" property
    pub fn get_pr(&self) -> Option<u32> {
        if self.0.has_pr() {
            Some(self.0.get_pr())
        } else {
            None
        }
    }

    /// set the value of the "pr" property
    pub fn set_pr(&mut self, pr: u32) {
        self.0.set_pr(pr);
    }

    /// get the value of the "pw" property
    pub fn get_pw(&self) -> Option<u32> {
        if self.0.has_pw() {
            Some(self.0.get_pw())
        } else {
            None
        }
    }

    /// set the value of the "pw" property
    pub fn set_pw(&mut self, pw: u32) {
        self.0.set_pw(pw);
    }

    /// get the value of the "rw" property
    pub fn get_rw(&self) -> Option<u32> {
        if self.0.has_rw() {
            Some(self.0.get_rw())
        } else {
            None
        }
    }

    /// set the value of the "rw" property
    pub fn set_rw(&mut self, rw: u32) {
        self.0.set_rw(rw);
    }

    /// get the value of the "r" property
    pub fn get_r(&self) -> Option<u32> {
        if self.0.has_r() {
            Some(self.0.get_r())
        } else {
            None
        }
    }

    /// set the value of the "r" property
    pub fn set_r(&mut self, r: u32) {
        self.0.set_r(r);
    }

    /// get the value of the "w" property
    pub fn get_w(&self) -> Option<u32> {
        if self.0.has_w() {
            Some(self.0.get_w())
        } else {
            None
        }
    }

    /// set the value of the "w" property
    pub fn set_w(&mut self, w: u32) {
        self.0.set_w(w);
    }

    /// get the value of the "n_val" property
    pub fn get_n_val(&self) -> Option<u32> {
        if self.0.has_n_val() {
            Some(self.0.get_n_val())
        } else {
            None
        }
    }

    /// set the value of the "n_val" property
    pub fn set_n_val(&mut self, n_val: u32) {
        self.0.set_n_val(n_val);
    }

    /// get the value of the "sloppy_quorum" property
    pub fn get_sloppy_quorum(&self) -> Option<bool> {
        if self.0.has_sloppy_quorum() {
            Some(self.0.get_sloppy_quorum())
        } else {
            None
        }
    }

    /// set the value of the "sloppy_quorum" property
    pub fn set_sloppy_quorum(&mut self, sloppy_quorum: bool) {
        self.0.set_sloppy_quorum(sloppy_quorum);
    }

    /// get the value of the "timeout" property
    pub fn get_timeout(&self) -> Option<u32> {
        if self.0.has_timeout() {
            Some(self.0.get_timeout())
        } else {
            None
        }
    }

    /// set the value of the "timeout" property
    pub fn set_timeout(&mut self, timeout: u32) {
        self.0.set_timeout(timeout);
    }

    /// get the value of the "vclock" property
    pub fn get_vclock(&self) -> Option<Vec<u8>> {
        if self.0.has_vclock() {
            let vclock = self.0.get_vclock().to_vec();
            Some(vclock)
        } else {
            None
        }
    }

    /// set the value of the "vclock" property
    pub fn set_vclock<T: Into<Vec<u8>>>(&mut self, vclock: T) {
        self.0.set_vclock(vclock.into());
    }
}

impl ProtobufBytes for DeleteObjectReq {
    fn write_to_bytes(self) -> Result<Vec<u8>, RiakErr> {
        match self.0.write_to_bytes() {
            Ok(bytes) => Ok(bytes),
            Err(error) => Err(RiakErr::ProtobufError(error)),
        }
    }
}

/// The data used to perform an store object request.
///
/// # Examples
///
/// ```
/// ```
#[derive(Clone, Debug)]
pub struct StoreObjectReq(RpbPutReq, ObjectContent);

impl StoreObjectReq {
    /// constructs a new `StoreObjectReq`
    pub fn new<T: Into<Vec<u8>>>(bucket: T, content: ObjectContent) -> StoreObjectReq {
        let mut rpb_put_req = RpbPutReq::new();
        rpb_put_req.set_bucket(bucket.into());
        StoreObjectReq(rpb_put_req, content)
    }

    /// get the "bucket" property
    pub fn get_bucket(&self) -> &[u8] {
        self.0.get_bucket()
    }

    /// set the "bucket" property
    pub fn set_bucket<T: Into<Vec<u8>>>(&mut self, bucket: T) {
        self.0.set_bucket(bucket.into());
    }

    /// get the "content" property
    pub fn get_content(&self) -> &ObjectContent {
        &self.1
    }

    /// set the "content" property
    pub fn set_content(&mut self, content: ObjectContent) {
        self.1 = content;
    }

    /// get the "asis" property
    pub fn get_asis(&self) -> Option<bool> {
        if self.0.has_asis() {
            Some(self.0.get_asis())
        } else {
            None
        }
    }

    /// set the "asis" property
    pub fn set_asis(&mut self, asis: bool) {
        self.0.set_asis(asis);
    }

    /// get the "bucket_type" property
    pub fn get_bucket_type(&self) -> Option<&[u8]> {
        if self.0.has_field_type() {
            Some(self.0.get_field_type())
        } else {
            None
        }
    }

    /// set the "bucket_type" property
    pub fn set_bucket_type<T: Into<Vec<u8>>>(&mut self, bucket_type: T) {
        self.0.set_field_type(bucket_type.into());
    }

    /// get the "if_none_match" property
    pub fn get_if_none_match(&self) -> Option<bool> {
        if self.0.has_if_none_match() {
            Some(self.0.get_if_none_match())
        } else {
            None
        }
    }

    /// set the "if_none_match" property
    pub fn set_if_none_match(&mut self, if_none_match: bool) {
        self.0.set_if_none_match(if_none_match);
    }

    /// get the "if_not_modified" property
    pub fn get_if_not_modified(&self) -> Option<bool> {
        if self.0.has_if_not_modified() {
            Some(self.0.get_if_not_modified())
        } else {
            None
        }
    }

    /// set the "if_not_modified" property
    pub fn set_if_not_modified(&mut self, if_not_modified: bool) {
        self.0.set_if_not_modified(if_not_modified);
    }

    /// get the "key" property
    pub fn get_key(&self) -> Option<&[u8]> {
        if self.0.has_key() {
            Some(self.0.get_key())
        } else {
            None
        }
    }

    /// set the "key" property
    pub fn set_key<T: Into<Vec<u8>>>(&mut self, key: T) {
        self.0.set_key(key.into());
    }

    /// get the "n_val" property
    pub fn get_n_val(&self) -> Option<u32> {
        if self.0.has_n_val() {
            Some(self.0.get_n_val())
        } else {
            None
        }
    }

    /// set the "n_val" property
    pub fn set_n_val(&mut self, n_val: u32) {
        self.0.set_n_val(n_val);
    }

    /// get the "return_body" property
    pub fn get_return_body(&self) -> Option<bool> {
        if self.0.has_return_body() {
            Some(self.0.get_return_body())
        } else {
            None
        }
    }

    /// set the "return_body" property
    pub fn set_return_body(&mut self, return_body: bool) {
        self.0.set_return_body(return_body);
    }

    /// get the "return_head" property
    pub fn get_return_head(&self) -> Option<bool> {
        if self.0.has_return_head() {
            Some(self.0.get_return_head())
        } else {
            None
        }
    }

    /// set the "return_head" property
    pub fn set_return_head(&mut self, return_head: bool) {
        self.0.set_return_head(return_head);
    }

    /// get the "sloppy_quorum" property
    pub fn get_sloppy_quorum(&self) -> Option<bool> {
        if self.0.has_sloppy_quorum() {
            Some(self.0.get_sloppy_quorum())
        } else {
            None
        }
    }

    /// set the "sloppy_quorum" property
    pub fn set_sloppy_quorum(&mut self, sloppy_quorum: bool) {
        self.0.set_sloppy_quorum(sloppy_quorum);
    }

    /// get the "timeout" property
    pub fn get_timeout(&self) -> Option<u32> {
        if self.0.has_timeout() {
            Some(self.0.get_timeout())
        } else {
            None
        }
    }

    /// set the "timeout" property
    pub fn set_timeout(&mut self, timeout: u32) {
        self.0.set_timeout(timeout);
    }

    /// get the "vclock" property
    pub fn get_vclock(&self) -> Option<&[u8]> {
        if self.0.has_vclock() {
            Some(self.0.get_vclock())
        } else {
            None
        }
    }

    /// set the "vclock" property
    pub fn set_vclock<T: Into<Vec<u8>>>(&mut self, vclock: T) {
        self.0.set_vclock(vclock.into());
    }

    /// get the "dw" property
    pub fn get_dw(&self) -> Option<u32> {
        if self.0.has_dw() {
            Some(self.0.get_dw())
        } else {
            None
        }
    }

    /// set the "dw" property
    pub fn set_dw(&mut self, dw: u32) {
        self.0.set_dw(dw);
    }

    /// get the "pw" property
    pub fn get_pw(&self) -> Option<u32> {
        if self.0.has_pw() {
            Some(self.0.get_pw())
        } else {
            None
        }
    }

    /// set the "pw" property
    pub fn set_pw(&mut self, pw: u32) {
        self.0.set_pw(pw);
    }

    /// get the "w" property
    pub fn get_w(&self) -> Option<u32> {
        if self.0.has_w() {
            Some(self.0.get_w())
        } else {
            None
        }
    }

    /// set the "w" property
    pub fn set_w(&mut self, w: u32) {
        self.0.set_w(w);
    }
}

impl ProtobufBytes for StoreObjectReq {
    fn write_to_bytes(mut self) -> Result<Vec<u8>, RiakErr> {
        if !self.0.has_content() {
            self.0.set_content(self.1.into_rpb())
        }
        match self.0.write_to_bytes() {
            Ok(bytes) => Ok(bytes),
            Err(error) => Err(RiakErr::ProtobufError(error)),
        }
    }
}

/// The data used to perform a fetch object request
///
/// # Examples
///
/// ```
/// ```
#[derive(Clone, Debug)]
pub struct FetchObjectReq(RpbGetReq);

impl FetchObjectReq {
    /// constructs a new `FetchObjectReq`
    pub fn new<T: Into<Vec<u8>>>(bucket: T, key: T) -> FetchObjectReq {
        let mut req = RpbGetReq::new();
        req.set_bucket(bucket.into());
        req.set_key(key.into());
        FetchObjectReq(req)
    }

    /// get the "bucket" property
    pub fn get_bucket(&self) -> &[u8] {
        self.0.get_bucket()
    }

    /// set the "bucket" property
    pub fn set_bucket<T: Into<Vec<u8>>>(&mut self, bucket: T) {
        self.0.set_bucket(bucket.into());
    }

    /// get the "key" property
    pub fn get_key(&self) -> &[u8] {
        self.0.get_key()
    }

    /// set the "key" property
    pub fn set_key<T: Into<Vec<u8>>>(&mut self, key: T) {
        self.0.set_key(key.into());
    }

    /// get the "r" property
    pub fn get_r(&self) -> Option<u32> {
        if self.0.has_r() {
            Some(self.0.get_r())
        } else {
            None
        }
    }

    /// set the "r" property
    pub fn set_r(&mut self, r: u32) {
        self.0.set_r(r);
    }

    /// get the "pr" property
    pub fn get_pr(&self) -> Option<u32> {
        if self.0.has_pr() {
            Some(self.0.get_pr())
        } else {
            None
        }
    }

    /// set the "pr" property
    pub fn set_pr(&mut self, pr: u32) {
        self.0.set_pr(pr);
    }

    /// get the "basic_quorum" property
    pub fn get_basic_quorum(&self) -> Option<bool> {
        if self.0.has_basic_quorum() {
            Some(self.0.get_basic_quorum())
        } else {
            None
        }
    }

    /// set the "basic_quorum" property
    pub fn set_basic_quorum(&mut self, basic_quorum: bool) {
        self.0.set_basic_quorum(basic_quorum);
    }

    /// get the "notfound_ok" property
    pub fn get_notfound_ok(&self) -> Option<bool> {
        if self.0.has_notfound_ok() {
            Some(self.0.get_notfound_ok())
        } else {
            None
        }
    }

    /// set the "notfound_ok" property
    pub fn set_notfound_ok(&mut self, notfound_ok: bool) {
        self.0.set_notfound_ok(notfound_ok);
    }

    /// get the "if_modified" property
    pub fn get_if_modified(&self) -> Option<&[u8]> {
        if self.0.has_if_modified() {
            Some(self.0.get_if_modified())
        } else {
            None
        }
    }

    /// set the "if_modified" property
    pub fn set_if_modified<T: Into<Vec<u8>>>(&mut self, if_modified: T) {
        self.0.set_if_modified(if_modified.into());
    }

    /// get the "head" property
    pub fn get_head(&self) -> Option<bool> {
        if self.0.has_head() {
            Some(self.0.get_head())
        } else {
            None
        }
    }

    /// set the "head" property
    pub fn set_head(&mut self, head: bool) {
        self.0.set_head(head);
    }

    /// get the "deleted_vclock" property
    pub fn get_deleted_vclock(&self) -> Option<bool> {
        if self.0.has_deletedvclock() {
            Some(self.0.get_deletedvclock())
        } else {
            None
        }
    }

    /// set the "deleted_vclock" property
    pub fn set_deleted_vclock(&mut self, deleted_vclock: bool) {
        self.0.set_deletedvclock(deleted_vclock);
    }

    /// get the "timeout" property
    pub fn get_timeout(&self) -> Option<u32> {
        if self.0.has_timeout() {
            Some(self.0.get_timeout())
        } else {
            None
        }
    }

    /// set the "timeout" property
    pub fn set_timeout(&mut self, timeout: u32) {
        self.0.set_timeout(timeout);
    }

    /// get the "sloppy_quorum" property
    pub fn get_sloppy_quorum(&self) -> Option<bool> {
        if self.0.has_sloppy_quorum() {
            Some(self.0.get_sloppy_quorum())
        } else {
            None
        }
    }

    /// set the "sloppy_quorum" property
    pub fn set_sloppy_quorum(&mut self, sloppy_quorum: bool) {
        self.0.set_sloppy_quorum(sloppy_quorum);
    }

    /// get the "n_val" property
    pub fn get_n_val(&self) -> Option<u32> {
        if self.0.has_n_val() {
            Some(self.0.get_n_val())
        } else {
            None
        }
    }

    /// set the "n_val" property
    pub fn set_n_val(&mut self, n_val: u32) {
        self.0.set_n_val(n_val);
    }

    /// get the "bucket_type" property
    pub fn get_bucket_type(&self) -> Option<&[u8]> {
        if self.0.has_field_type() {
            Some(self.0.get_field_type())
        } else {
            None
        }
    }

    /// set the "bucket_type" property
    pub fn set_bucket_type<T: Into<Vec<u8>>>(&mut self, bucket_type: T) {
        self.0.set_field_type(bucket_type.into());
    }
}

impl ProtobufBytes for FetchObjectReq {
    fn write_to_bytes(self) -> Result<Vec<u8>, RiakErr> {
        match self.0.write_to_bytes() {
            Ok(bytes) => Ok(bytes),
            Err(err) => Err(RiakErr::ProtobufError(err)),
        }
    }
}

/// Represents the response received from Riak, including all siblings of the object,
/// the vector clock, and "unchanged" if "if_modified" was set to true in the request.
#[derive(Clone, Debug)]
pub struct FetchObjectResp {
    content: Vec<ObjectContent>,
    vclock: Vec<u8>,
    unchanged: Option<bool>,
}

impl FetchObjectResp {
    pub fn new(content: &Vec<ObjectContent>, vclock: &[u8]) -> FetchObjectResp {
        FetchObjectResp {
            content: content.clone(),
            vclock: vclock.to_vec(),
            unchanged: None,
        }
    }

    pub fn get_content(&self) -> Vec<ObjectContent> {
        self.content.clone()
    }

    pub fn set_content(&mut self, content: Vec<ObjectContent>) {
        self.content = content;
    }

    pub fn get_vclock(&self) -> Vec<u8> {
        self.vclock.clone()
    }

    pub fn set_vclock(&mut self, vclock: Vec<u8>) {
        self.vclock = vclock;
    }

    pub fn get_unchanged(&self) -> Option<bool> {
        self.unchanged
    }

    pub fn set_unchanged(&mut self, unchanged: bool) {
        self.unchanged = Some(unchanged);
    }
}

impl FetchObjectRespPrivate for FetchObjectResp {
    fn new_from_rpb(mut rpb: RpbGetResp) -> FetchObjectResp {
        let mut contents: Vec<ObjectContent> = Vec::new();

        let rpb_content = rpb.take_content();
        for content in rpb_content.into_iter() {
            contents.push(ObjectContent::new_from_rpb(content));
        }

        let mut response = FetchObjectResp {
            content: contents,
            vclock: rpb.take_vclock(),
            unchanged: None,
        };

        if rpb.has_unchanged() {
            response.set_unchanged(rpb.get_unchanged());
        }

        response
    }
}


/// Represents the actual value and metadata for the value being stored in Riak.
///
/// # Examples
///
/// ```
/// ```
#[derive(Clone, Debug, Default)]
pub struct ObjectContent(RpbContent);

impl ObjectContent {
    pub fn new<T: Into<Vec<u8>>>(value: T) -> ObjectContent {
        let mut content: ObjectContent = Default::default();
        content.set_value(value.into());
        content
    }

    /// gets the "value" property
    pub fn get_value(&self) -> &[u8] {
        self.0.get_value()
    }

    /// sets the "value" property
    pub fn set_value<T: Into<Vec<u8>>>(&mut self, value: T) {
        self.0.set_value(value.into());
    }

    /// gets the "content_type" property
    pub fn get_content_type(&self) -> Option<&[u8]> {
        if self.0.has_content_type() {
            Some(self.0.get_content_type())
        } else {
            None
        }
    }

    /// sets the "content_type" property
    pub fn set_content_type<T: Into<Vec<u8>>>(&mut self, content_type: T) {
        self.0.set_content_type(content_type.into());
    }

    /// gets the "charset" property
    pub fn get_charset(&self) -> Option<&[u8]> {
        if self.0.has_charset() {
            Some(self.0.get_charset())
        } else {
            None
        }
    }

    /// set the "charset" property
    pub fn set_charset<T: Into<Vec<u8>>>(&mut self, charset: T) {
        self.0.set_charset(charset.into());
    }

    /// get the "content_encoding" property
    pub fn get_content_encoding(&self) -> Option<&[u8]> {
        if self.0.has_content_encoding() {
            Some(self.0.get_content_encoding())
        } else {
            None
        }
    }

    /// set the "content_encoding" property
    pub fn set_content_encoding<T: Into<Vec<u8>>>(&mut self, content_encoding: T) {
        self.0.set_content_encoding(content_encoding.into());
    }

    /// get the "vtag" property
    pub fn get_vtag(&self) -> Option<&[u8]> {
        if self.0.has_vtag() {
            Some(self.0.get_vtag())
        } else {
            None
        }
    }

    /// set the "vtag" property
    pub fn set_vtag<T: Into<Vec<u8>>>(&mut self, vtag: T) {
        self.0.set_vtag(vtag.into());
    }

    /// get the "last_mod" property
    pub fn get_last_mod(&self) -> Option<u32> {
        if self.0.has_last_mod() {
            Some(self.0.get_last_mod())
        } else {
            None
        }
    }

    /// set the "last_mod" property
    pub fn set_last_mod(&mut self, last_mod: u32) {
        self.0.set_last_mod(last_mod);
    }

    /// get the "last_mod_usecs" property
    pub fn get_last_mod_usecs(&self) -> Option<u32> {
        if self.0.has_last_mod_usecs() {
            Some(self.0.get_last_mod_usecs())
        } else {
            None
        }
    }

    /// set the "last_mod_usecs" property
    pub fn set_last_mod_usecs(&mut self, last_mod_usecs: u32) {
        self.0.set_last_mod_usecs(last_mod_usecs);
    }

    /// get the "deleted" property
    pub fn get_deleted(&self) -> Option<bool> {
        if self.0.has_deleted() {
            Some(self.0.get_deleted())
        } else {
            None
        }
    }

    /// set the "deleted" property
    pub fn set_deleted(&mut self, deleted: bool) {
        self.0.set_deleted(deleted);
    }
}

impl ObjectContentPrivate for ObjectContent {
    fn into_rpb(self) -> RpbContent {
        self.0
    }

    fn new_from_rpb(rpb_content: RpbContent) -> ObjectContent {
        ObjectContent(rpb_content)
    }
}