pub trait AccountSpec {
fn new(username: String, password: String) -> Self
where
Self: Sized;
fn id(&self) -> scsys::bson::oid::ObjectId;
fn name(&self) -> String;
fn password(&self) -> String;
fn slug(&self) -> String {
self.name().clone().to_lowercase()
}
fn username(&self) -> String;
}
#[derive(Clone, Debug, Hash, PartialEq, scsys::Deserialize, scsys::Serialize)]
pub struct Web3Account {
pub address: String,
pub balance: usize,
pub ensname: String,
}
impl Web3Account {
fn constructor(address: String, balance: usize, ensname: String) -> Self {
Self {
address,
balance,
ensname,
}
}
pub fn new(address: String, balance: usize, ensname: String) -> Self {
Self::constructor(address, balance, ensname)
}
pub fn get_balance(&self) -> usize {
todo!()
}
}
impl Default for Web3Account {
fn default() -> Self {
Self::new(String::new(), 0, String::new())
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_account() {
let actual = Web3Account::default();
let expected = actual.clone();
assert_eq!(actual, expected)
}
}