Skip to content
Snippets Groups Projects
Select Git revision
  • ad0019522ffdf6201d8c20c7f015e3e0245430c9
  • master default protected
  • polkadart-stuff
  • dev
  • provider-to-riverpod
  • implementLightnode
  • subscribesSplit
  • hugo_RML16
  • refactorOnboardingSlideshow
  • duniterV1Latest
  • scanNetwork
  • dubp_rs
  • v0.2.3+119
  • v0.2.2+118
  • v0.2.1+113
  • polkawallet-sdk-latest
  • v0.1.29+111
  • v0.1.28+109
  • v0.1.27+108
  • v0.1.26+107
  • v0.1.25+106
  • v0.1.25+105
  • v0.1.24+102
  • v0.1.23+101
  • v0.1.22+100
  • v0.1.22+99
  • v0.1.21+98
  • v0.1.21+97
  • v0.1.21+96
  • v0.1.21+95
  • v0.1.21+94
  • v0.1.21+93
32 results

wallet_view.dart

Blame
  • gva_block_db.rs 1.84 KiB
    //  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 <https://www.gnu.org/licenses/>.
    
    use crate::*;
    use dubp::block::{DubpBlock, DubpBlockV10};
    
    #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
    #[repr(transparent)]
    pub struct GvaBlockDbV1(pub DubpBlock);
    
    impl Default for GvaBlockDbV1 {
        fn default() -> Self {
            Self(DubpBlock::V10(DubpBlockV10::default()))
        }
    }
    
    impl AsBytes for GvaBlockDbV1 {
        fn as_bytes<T, F: FnMut(&[u8]) -> T>(&self, mut f: F) -> T {
            f(&bincode::serialize(&self).unwrap_or_else(|_| unreachable!()))
        }
    }
    
    impl kv_typed::prelude::FromBytes for GvaBlockDbV1 {
        type Err = bincode::Error;
    
        fn from_bytes(bytes: &[u8]) -> std::result::Result<Self, Self::Err> {
            bincode::deserialize(bytes)
        }
    }
    
    impl ToDumpString for GvaBlockDbV1 {
        fn to_dump_string(&self) -> String {
            todo!()
        }
    }
    
    #[cfg(feature = "explorer")]
    impl ExplorableValue for GvaBlockDbV1 {
        fn from_explorer_str(source: &str) -> Result<Self, FromExplorerValueErr> {
            serde_json::from_str(source).map_err(|e| FromExplorerValueErr(e.into()))
        }
        fn to_explorer_json(&self) -> KvResult<serde_json::Value> {
            serde_json::to_value(&self).map_err(|e| KvError::DeserError(e.into()))
        }
    }