Changeset View
Changeset View
Standalone View
Standalone View
cpp/src/account.rs
| use super::{ | use super::{ | ||||
| ffi::{InboundCreationResult, OlmMessageParts, OneTimeKey}, | ffi::{InboundCreationResult, OlmMessageParts, OneTimeKey}, | ||||
| Curve25519PublicKey, Ed25519PublicKey, Ed25519Signature, Session, | Curve25519PublicKey, Ed25519PublicKey, Ed25519Signature, Session, | ||||
| }; | }; | ||||
| use vodozemac_maybe_derive::gen_noexcept; | use vodozemac_maybe_derive::gen_noexcept; | ||||
| use crate::maybe::Maybe; | use crate::maybe::Maybe; | ||||
| pub struct OlmMessage(pub(crate) vodozemac::olm::OlmMessage); | pub struct OlmMessage(pub(crate) vodozemac::olm::OlmMessage); | ||||
| impl OlmMessage { | impl OlmMessage { | ||||
| pub fn to_parts(&self) -> OlmMessageParts { | pub fn to_parts(&self) -> OlmMessageParts { | ||||
| let (message_type, ciphertext) = self.0.clone().to_parts(); | let (message_type, ciphertext) = self.0.clone().to_parts(); | ||||
| OlmMessageParts { | OlmMessageParts { | ||||
| ciphertext, | ciphertext: vodozemac::base64_encode(ciphertext), | ||||
| message_type, | message_type, | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| #[gen_noexcept] | #[gen_noexcept] | ||||
| pub fn olm_message_from_parts(parts: &OlmMessageParts) -> Result<Box<OlmMessage>, anyhow::Error> { | pub fn olm_message_from_parts(parts: &OlmMessageParts) -> Result<Box<OlmMessage>, anyhow::Error> { | ||||
| Ok(OlmMessage(vodozemac::olm::OlmMessage::from_parts( | Ok(OlmMessage(vodozemac::olm::OlmMessage::from_parts( | ||||
| parts.message_type, | parts.message_type, | ||||
| &parts.ciphertext, | vodozemac::base64_decode(&parts.ciphertext)?.as_slice(), | ||||
| )?) | )?) | ||||
| .into()) | .into()) | ||||
| } | } | ||||
| pub struct OneTimeKeyGenerationResult(vodozemac::olm::OneTimeKeyGenerationResult); | pub struct OneTimeKeyGenerationResult(vodozemac::olm::OneTimeKeyGenerationResult); | ||||
| impl OneTimeKeyGenerationResult { | impl OneTimeKeyGenerationResult { | ||||
| pub fn created(self: &Self) -> Vec<Curve25519PublicKey> { | pub fn created(self: &Self) -> Vec<Curve25519PublicKey> { | ||||
| ▲ Show 20 Lines • Show All 129 Lines • Show Last 20 Lines | |||||