go-tg-screenshot-bot

Форк
0
69 строк · 1.7 Кб
1
package dbus
2

3
import (
4
	"context"
5
	"errors"
6
)
7

8
var errSignature = errors.New("dbus: mismatched signature")
9

10
// Call represents a pending or completed method call.
11
type Call struct {
12
	Destination string
13
	Path        ObjectPath
14
	Method      string
15
	Args        []interface{}
16

17
	// Strobes when the call is complete.
18
	Done chan *Call
19

20
	// After completion, the error status. If this is non-nil, it may be an
21
	// error message from the peer (with Error as its type) or some other error.
22
	Err error
23

24
	// Holds the response once the call is done.
25
	Body []interface{}
26

27
	// ResponseSequence stores the sequence number of the DBus message containing
28
	// the call response (or error). This can be compared to the sequence number
29
	// of other call responses and signals on this connection to determine their
30
	// relative ordering on the underlying DBus connection.
31
	// For errors, ResponseSequence is populated only if the error came from a
32
	// DBusMessage that was received or if there was an error receiving. In case of
33
	// failure to make the call, ResponseSequence will be NoSequence.
34
	ResponseSequence Sequence
35

36
	// tracks context and canceler
37
	ctx         context.Context
38
	ctxCanceler context.CancelFunc
39
}
40

41
func (c *Call) Context() context.Context {
42
	if c.ctx == nil {
43
		return context.Background()
44
	}
45

46
	return c.ctx
47
}
48

49
func (c *Call) ContextCancel() {
50
	if c.ctxCanceler != nil {
51
		c.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.
58
func (c *Call) Store(retvalues ...interface{}) error {
59
	if c.Err != nil {
60
		return c.Err
61
	}
62

63
	return Store(c.Body, retvalues...)
64
}
65

66
func (c *Call) done() {
67
	c.Done <- c
68
	c.ContextCancel()
69
}
70

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.