// Copyright (C) 2020 Éloïs SANCHEZ.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see .
use crate::*;
#[derive(Clone, Copy, Debug)]
pub(crate) enum SecretCodeType {
Digits,
Letters,
}
impl From for SecretCodeType {
fn from(i: u32) -> Self {
if i == 0 {
SecretCodeType::Digits
} else {
SecretCodeType::Letters
}
}
}
#[derive(Clone, Copy, Debug)]
pub(crate) enum WalletType {
Ed25519,
Bip32Ed25519,
}
impl From for WalletType {
fn from(i: u32) -> Self {
if i == 1 {
WalletType::Bip32Ed25519
} else {
WalletType::Ed25519
}
}
}
pub(crate) fn char_ptr_to_str<'a>(c_char_ptr: *const raw::c_char) -> Result<&'a str, DubpError> {
if c_char_ptr.is_null() {
Err(DubpError::NullParamErr)
} else {
unsafe { CStr::from_ptr(c_char_ptr).to_str() }.map_err(DubpError::Utf8Error)
}
}
pub(crate) fn char_ptr_to_opt_string(
c_char_ptr: *const raw::c_char,
) -> Result