Documentation
¶
Overview ¶
use pubkey::Pubkey;
use bs58; use generic_array::typenum::U32; use generic_array::GenericArray; use std::fmt;
#[derive(Serialize, Deserialize, Clone, Copy, Default, Eq, PartialEq, Ord, PartialOrd, Hash)] pub struct Pubkey(GenericArray<u8, U32>); the source code for this can be found here https://github.com/fizyk20/generic-array/blob/30f0cc938f6cfcd41da42966f990a00653abbc7d/src/impls.rs
Pubkey is a struct returns a array of [T;N], An array of N elements of type T is written in Rust as [T; N]. This can be treated as a array struct
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
impl Pubkey { pub fn new(pubkey_vec: &[u8]) -> Self { Pubkey(GenericArray::clone_from_slice(&pubkey_vec)) } }
clone_from_slice returns a generci array wiht input from pubkey_vec
New is a method of sturct Pubkey, return a Pubkey struct, refer to clone_from_slice method
input :an uint8 array output :an array (slice ) of
Types ¶
type Account ¶
Account is a data structure stores userdata in the ledger file
func NewAccount ¶
NewAccount is the method of Account, returns a Account struct search keyword:new, method , struct in go-ethereum to find similar use case find a similar case in go-ethereum/core/vm/logger.go also refer to this https://github.com/golang/go/wiki/CodeReviewComments#interfaces
type Array ¶
type Array struct { T []uint8 //values of the array N uint32 //current length of the array Cap uint32 //cap length of the array, possible maximum }
Array is a struct
type Pubkey ¶
type Pubkey []uint8
Pubkey returns an array struct of uint8, with the size of uint32 search ""
func (Pubkey) Asref ¶
func (arguments Pubkey) Asref()
Asref
return the full range of the array
impl AsRef<[u8]> for Pubkey { fn as_ref(&self) -> &[u8] { &self.0[..] } }
AsRef is a Trait implementation, ref:https://doc.rust-lang.org/reference/items/implementations.html https://doc.rust-lang.org/stable/book/ch10-02-traits.html Implementing a trait on a type is similar to implementing regular methods. the Asref can be thought as a method for Pubkey Notes: search ":AsRef" in MVP, no where it is used, just ignore this one