go-tg-screenshot-bot
69 строк · 1.7 Кб
1package dbus2
3import (4"context"5"errors"6)
7
8var errSignature = errors.New("dbus: mismatched signature")9
10// Call represents a pending or completed method call.
11type Call struct {12Destination string13Path ObjectPath
14Method string15Args []interface{}16
17// Strobes when the call is complete.18Done chan *Call19
20// After completion, the error status. If this is non-nil, it may be an21// error message from the peer (with Error as its type) or some other error.22Err error23
24// Holds the response once the call is done.25Body []interface{}26
27// ResponseSequence stores the sequence number of the DBus message containing28// the call response (or error). This can be compared to the sequence number29// of other call responses and signals on this connection to determine their30// relative ordering on the underlying DBus connection.31// For errors, ResponseSequence is populated only if the error came from a32// DBusMessage that was received or if there was an error receiving. In case of33// failure to make the call, ResponseSequence will be NoSequence.34ResponseSequence Sequence
35
36// tracks context and canceler37ctx context.Context38ctxCanceler context.CancelFunc39}
40
41func (c *Call) Context() context.Context {42if c.ctx == nil {43return context.Background()44}45
46return c.ctx47}
48
49func (c *Call) ContextCancel() {50if c.ctxCanceler != nil {51c.ctxCanceler()52}53}
54
55// Store stores the body of the reply into the provided pointers. It returns
56// an error if the signatures of the body and retvalues don't match, or if
57// the error status is not nil.
58func (c *Call) Store(retvalues ...interface{}) error {59if c.Err != nil {60return c.Err61}62
63return Store(c.Body, retvalues...)64}
65
66func (c *Call) done() {67c.Done <- c68c.ContextCancel()69}
70