substrate_stellar_sdk/xdr/impls/
account_id.rs1use crate::{AccountId, MuxedAccount, StellarSdkError};
2use sp_std::vec::Vec;
3
4pub trait IntoAccountId: Sized {
5 fn into_account_id(self) -> Result<AccountId, StellarSdkError>;
6
7 fn into_encoding(self) -> Vec<u8>;
11}
12
13impl IntoAccountId for AccountId {
14 fn into_account_id(self) -> Result<AccountId, StellarSdkError> {
15 Ok(self)
16 }
17
18 fn into_encoding(self) -> Vec<u8> {
19 self.to_encoding()
20 }
21}
22
23impl<T: AsRef<[u8]>> IntoAccountId for T {
24 fn into_account_id(self) -> Result<AccountId, StellarSdkError> {
25 Ok(AccountId::from_encoding(self)?)
26 }
27
28 fn into_encoding(self) -> Vec<u8> {
29 self.as_ref().to_vec()
30 }
31}
32
33impl From<AccountId> for MuxedAccount {
34 fn from(account_id: AccountId) -> Self {
35 MuxedAccount::KeyTypeEd25519(account_id.into_binary())
36 }
37}