forked from warthog618/sms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.go
58 lines (47 loc) · 1.18 KB
/
options.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// SPDX-License-Identifier: MIT
//
// Copyright © 2020 Kent Gibson <[email protected]>.
package tpdu
// Option applies a construction option to a TPDU.
type Option interface {
ApplyTPDUOption(*TPDU) error
}
// DAOption specifies the DA for the TPDU.
type DAOption struct {
addr Address
}
// ApplyTPDUOption applies the DA to the TPDU.
func (o DAOption) ApplyTPDUOption(t *TPDU) error {
t.DA = o.addr
return nil
}
// WithDA creates a DAOption to apply to a TPDU.
func WithDA(addr Address) DAOption {
return DAOption{addr}
}
// OAOption specifies the OA for the TPDU.
type OAOption struct {
addr Address
}
// ApplyTPDUOption applies the OA to the TPDU.
func (o OAOption) ApplyTPDUOption(t *TPDU) error {
t.OA = o.addr
return nil
}
// WithOA creates a OAOption to apply to a TPDU.
func WithOA(addr Address) OAOption {
return OAOption{addr}
}
// UDHOption specifies the UDH for the TPDU.
type UDHOption struct {
udh UserDataHeader
}
// ApplyTPDUOption applies the UDH to the TPDU.
func (o UDHOption) ApplyTPDUOption(t *TPDU) error {
t.UDH = o.udh
return nil
}
// WithUDH creates a UDHOption to apply to a TPDU.
func WithUDH(udh UserDataHeader) UDHOption {
return UDHOption{udh}
}