MCPcopy Create free account
hub / github.com/digitalocean/go-libvirt / Decode

Method Decode

rpc.go:418–433  ·  view source on GitHub ↗

Decode decodes a TypedParam. These are part of the libvirt spec, and not xdr proper. TypedParams contain a name, which is called Field for some reason, and a Value, which itself has a "discriminant" - an integer enum encoding the actual type, and a value, the length of which varies based on the actu

(d *xdr.Decoder, v reflect.Value)

Source from the content-addressed store, hash-verified

416// actual type, and a value, the length of which varies based on the actual
417// type.
418func (tpd typedParamDecoder) Decode(d *xdr.Decoder, v reflect.Value) (int, error) {
419 // Get the name of the typed param first
420 name, n, err := d.DecodeString()
421 if err != nil {
422 return n, err
423 }
424 val, n2, err := tpd.decodeTypedParamValue(d)
425 n += n2
426 if err != nil {
427 return n, err
428 }
429 tp := &TypedParam{Field: name, Value: *val}
430 v.Set(reflect.ValueOf(*tp))
431
432 return n, nil
433}
434
435// decodeTypedParamValue decodes the Value part of a TypedParam.
436func (typedParamDecoder) decodeTypedParamValue(d *xdr.Decoder) (*TypedParamValue, int, error) {

Callers

nothing calls this directly

Calls 2

decodeTypedParamValueMethod · 0.95
DecodeStringMethod · 0.80

Tested by

no test coverage detected