github.com/machinefi/w3bstream@v1.6.5-rc9.0.20240426031326-b8c7c4876e72/pkg/modules/wasm/consts/result.go (about)

     1  package consts
     2  
     3  //go:generate toolkit gen enum Result
     4  type Result int32
     5  
     6  const (
     7  	RESULT_UNKNOWN Result = iota
     8  	RESULT__INVALID_MEM_ACCESS
     9  	RESULT__ENV_NOT_FOUND
    10  	RESULT__RESOURCE_NOT_FOUND
    11  	RESULT__RESOURCE_EVENT_NOT_FOUND
    12  	RESULT__KV_DATA_NOT_FOUND
    13  	RESULT__IMPORT_HANDLE_FAILED
    14  	RESULT__HOST_INVOKE_FAILED
    15  )
    16  
    17  const RESULT_OK = RESULT_UNKNOWN
    18  
    19  func (v Result) OK() bool {
    20  	return v == RESULT_OK
    21  }
    22  
    23  func (v Result) Error() string {
    24  	return v.String()
    25  }
    26  
    27  func (v Result) Int32() int32 {
    28  	return int32(v)
    29  }