-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement scylla traits for StrongSecret (#6500)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
- Loading branch information
1 parent
29be1d4
commit 7d73e90
Showing
4 changed files
with
171 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
use scylla::{ | ||
cql_to_rust::FromCqlVal, | ||
deserialize::DeserializeValue, | ||
frame::response::result::{ColumnType, CqlValue}, | ||
serialize::{ | ||
value::SerializeValue, | ||
writers::{CellWriter, WrittenCellProof}, | ||
SerializationError, | ||
}, | ||
}; | ||
|
||
use crate::{abs::PeekInterface, StrongSecret}; | ||
|
||
impl<T> SerializeValue for StrongSecret<T> | ||
where | ||
T: SerializeValue + zeroize::Zeroize + Clone, | ||
{ | ||
fn serialize<'b>( | ||
&self, | ||
typ: &ColumnType, | ||
writer: CellWriter<'b>, | ||
) -> Result<WrittenCellProof<'b>, SerializationError> { | ||
self.peek().serialize(typ, writer) | ||
} | ||
} | ||
|
||
impl<'frame, T> DeserializeValue<'frame> for StrongSecret<T> | ||
where | ||
T: DeserializeValue<'frame> + zeroize::Zeroize + Clone, | ||
{ | ||
fn type_check(typ: &ColumnType) -> Result<(), scylla::deserialize::TypeCheckError> { | ||
T::type_check(typ) | ||
} | ||
|
||
fn deserialize( | ||
typ: &'frame ColumnType, | ||
v: Option<scylla::deserialize::FrameSlice<'frame>>, | ||
) -> Result<Self, scylla::deserialize::DeserializationError> { | ||
Ok(Self::new(T::deserialize(typ, v)?)) | ||
} | ||
} | ||
|
||
impl<T> FromCqlVal<CqlValue> for StrongSecret<T> | ||
where | ||
T: FromCqlVal<CqlValue> + zeroize::Zeroize + Clone, | ||
{ | ||
fn from_cql(cql_val: CqlValue) -> Result<Self, scylla::cql_to_rust::FromCqlValError> { | ||
Ok(Self::new(T::from_cql(cql_val)?)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters