Skip to content

Commit f199160

Browse files
author
Nicklas Warming Jacobsen
committed
Somewhat fixed new doc strings
1 parent bcf4159 commit f199160

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

vendor/cipherstash-client/src/encryption/plaintext/from_conversion.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ use rust_decimal::Decimal;
66
use super::{Plaintext, PlaintextNullVariant};
77
use crate::encryption::errors::TypeParseError;
88

9+
/// Trait for converting `Plaintext` to `Self`
910
pub trait TryFromPlaintext: Sized {
11+
/// Try to convert `value` to `Self`
1012
fn try_from_plaintext(value: &Plaintext) -> Result<Self, TypeParseError>;
1113
}
1214

@@ -40,10 +42,15 @@ impl_try_from_plaintext! {
4042
String => Utf8Str
4143
}
4244

45+
/// Blanket implementation of `Option<T>` for all `T` that implements `TryFromPlaintext`.
4346
impl<T> TryFromPlaintext for Option<T>
4447
where
4548
T: TryFromPlaintext + PlaintextNullVariant,
4649
{
50+
/// Returns an error if the `Plaintext` variant of `value` and `<T as PlaintextNullVariant>::null()` doesn't match
51+
/// or if `TryFromPlaintext::try_from_plaintext` returns an error.
52+
/// Returns `None` if the inner `Option` in `value` is `None`
53+
/// Returns `Ok(Some(Self))` if `Plaintext` value could successfully be converted
4754
fn try_from_plaintext(value: &Plaintext) -> Result<Self, TypeParseError> {
4855
match (value, T::null()) {
4956
// Return OK(None) if the inner value is None

vendor/cipherstash-client/src/encryption/plaintext/mod.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,9 @@ impl Plaintext {
285285
}
286286
}
287287

288+
/// Trait that defines the `None` or `Null` `Plaintext` variant of the implementing type.
288289
pub trait PlaintextNullVariant {
289-
/// Returns Self's corresponding Plaintext variant with None
290+
/// Returns Self's corresponding `Plaintext` variant with None
290291
fn null() -> Plaintext;
291292
}
292293

@@ -322,7 +323,7 @@ impl PlaintextNullVariant for &str {
322323
}
323324

324325
/// Blanket implementation for all references
325-
/// where the referenced type is clonable and implements ToPlaintext.
326+
/// where the referenced type implements `ToPlaintext`.
326327
impl<T> PlaintextNullVariant for &T
327328
where
328329
T: PlaintextNullVariant,
@@ -332,8 +333,8 @@ where
332333
}
333334
}
334335

335-
/// Blanket implementation for Option<T> where
336-
/// T implements ToPlaintext.
336+
/// Blanket implementation for `Option<T>` where
337+
/// `T` implements `PlaintextNullVariant`.
337338
impl<T> PlaintextNullVariant for Option<T>
338339
where
339340
T: PlaintextNullVariant,

vendor/cipherstash-client/src/encryption/plaintext/to_conversion.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ use super::{Plaintext, PlaintextNullVariant};
22
use chrono::{DateTime, NaiveDate, Utc};
33
use rust_decimal::Decimal;
44

5-
/// This trait works as a proxy for implementing `From<T> for Plaintext`.
6-
/// TODO Bla bla blanket impl on Option<T> and implementing From<T> for generic container types
5+
/// Trait for converting `Self` into `Plaintext`
76
pub trait ToPlaintext: super::PlaintextNullVariant {
8-
/// Converts Self into Plaintext
7+
/// Converts `Self` into `Plaintext`
98
fn to_plaintext(self) -> Plaintext;
109
}
1110

@@ -41,7 +40,7 @@ impl ToPlaintext for &str {
4140
}
4241

4342
/// Blanket implementation for all references
44-
/// where the referenced type is clonable and implements ToPlaintext.
43+
/// where the referenced type is clonable and implements `ToPlaintext`.
4544
impl<T> ToPlaintext for &T
4645
where
4746
T: ToPlaintext + Clone,
@@ -52,8 +51,8 @@ where
5251
}
5352
}
5453

55-
/// Blanket implementation for Option<T> where
56-
/// T implements ToPlaintext.
54+
/// Blanket implementation for `Option<T>` where
55+
/// `T` implements `ToPlaintext`.
5756
impl<T> ToPlaintext for Option<T>
5857
where
5958
T: ToPlaintext,
@@ -68,8 +67,8 @@ where
6867
}
6968
}
7069

71-
/// Blanket implementation of From<T> for all
72-
/// T that implements ToPlaintext
70+
/// Blanket implementation of `From<T>` for all
71+
/// `T` that implements `ToPlaintext`
7372
impl<T> From<T> for Plaintext
7473
where
7574
T: ToPlaintext,

0 commit comments

Comments
 (0)