pgminterface

package
v1.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 7, 2019 License: GPL-3.0, MIT Imports: 1 Imported by: 0

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

func New(size uint32) []uint8
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

type Account struct {
	//
	Tokens    int64
	UserData  []uint8
	ProgramID Pubkey
}

Account is a data structure stores userdata in the ledger file

func NewAccount

func NewAccount(tokens int64, space uint64, programID Pubkey) *Account

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

func NewArray

func NewArray(inputSlice []uint8, arrayCapacity uint32) (*Array, error)

NewArray is a method to create a new array using std lib in golang

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

func (Pubkey) Debug

func (arguments Pubkey) Debug()

Debug

impl fmt::Debug for Pubkey {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "{}", bs58::encode(self.0).into_string())
    }
}

Notes: search ":Debug" in MVP, no where it is used, just ignore this one

func (Pubkey) Display

func (arguments Pubkey) Display()

Display

impl fmt::Display for Pubkey {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "{}", bs58::encode(self.0).into_string())
    }
}

Notes: search ":Debug" in MVP, no where it is used, just ignore this one

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL