-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoptions.go
More file actions
55 lines (46 loc) · 1.15 KB
/
Copy pathoptions.go
File metadata and controls
55 lines (46 loc) · 1.15 KB
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
package gogige
import "time"
// Option configures Open / device connection.
type Option func(*openConfig)
type openConfig struct {
logger Logger
timeout time.Duration
component Component
}
// WithLogger sets the logger used by this device (default: NopLogger).
func WithLogger(l Logger) Option {
return func(c *openConfig) {
if l != nil {
c.logger = l
}
}
}
// WithTimeout sets the GVCP dial / control timeout (default: 2s).
func WithTimeout(d time.Duration) Option {
return func(c *openConfig) {
if d > 0 {
c.timeout = d
}
}
}
// WithComponent selects which BSCF/SFNC component GrabJPEG uses (color/depth/mono).
// Default: ComponentColor.
func WithComponent(comp Component) Option {
return func(c *openConfig) {
if comp != ComponentUnknown {
c.component = comp
}
}
}
// GrabOption configures StartGrabber / Session.
type GrabOption func(*Session)
// GrabComponent selects which BSCF/SFNC component Session.Grab decodes.
func GrabComponent(comp Component) GrabOption {
return func(s *Session) {
if s != nil && comp != ComponentUnknown {
s.component = comp
}
}
}
// Version is the library version.
const Version = "1.5.0"