Documentation ¶
Overview ¶
Package accounting provides primitives to perform accounting operations in NeoFS.
Decimal type provides functionality to process user balances.
Example ¶
package main import ( apiGoAccounting "github.com/nspcc-dev/neofs-api-go/v2/accounting" "github.com/nspcc-dev/neofs-sdk-go/accounting" ) func main() { var val int64 var dec accounting.Decimal dec.SetValue(val) dec.SetPrecision(8) // Instances can be also used to process NeoFS API V2 protocol messages. See neofs-api-go package. // On the client side. // import apiGoAccounting "github.com/nspcc-dev/neofs-api-go/v2/accounting" var msg apiGoAccounting.Decimal dec.WriteToV2(&msg) // *send message* // On the server side. _ = dec.ReadFromV2(msg) }
Output:
Index ¶
- type Decimal
- func (d Decimal) Marshal() []byte
- func (d Decimal) Precision() uint32
- func (d *Decimal) ReadFromV2(m accounting.Decimal) error
- func (d *Decimal) SetPrecision(p uint32)
- func (d *Decimal) SetValue(v int64)
- func (d *Decimal) Unmarshal(data []byte) error
- func (d Decimal) Value() int64
- func (d Decimal) WriteToV2(m *accounting.Decimal)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Decimal ¶
type Decimal accounting.Decimal
Decimal represents decimal number for accounting operations.
Decimal is mutually compatible with github.com/nspcc-dev/neofs-api-go/v2/accounting.Decimal message. See ReadFromV2 / WriteToV2 methods.
Instances can be created using built-in var declaration.
Note that direct typecast is not safe and may result in loss of compatibility:
_ = Decimal(accounting.Decimal{}) // not recommended
func (Decimal) Marshal ¶
Marshal encodes Decimal into a binary format of the NeoFS API protocol (Protocol Buffers with direct field order).
See also Unmarshal.
func (Decimal) Precision ¶
Precision returns precision of the decimal number.
Zero Decimal has zero precision.
See also SetPrecision.
func (*Decimal) ReadFromV2 ¶
func (d *Decimal) ReadFromV2(m accounting.Decimal) error
ReadFromV2 reads Decimal from the accounting.Decimal message. Checks if the message conforms to NeoFS API V2 protocol.
See also WriteToV2.
func (*Decimal) SetPrecision ¶
SetPrecision sets precision of the decimal number.
See also Precision.
func (*Decimal) Unmarshal ¶
Unmarshal decodes NeoFS API protocol binary format into the Decimal (Protocol Buffers with direct field order). Returns an error describing a format violation.
See also Marshal.
func (Decimal) Value ¶
Value returns value of the decimal number.
Zero Decimal has zero value.
See also SetValue.
func (Decimal) WriteToV2 ¶
func (d Decimal) WriteToV2(m *accounting.Decimal)
WriteToV2 writes Decimal to the accounting.Decimal message. The message must not be nil.
See also ReadFromV2.