Skip to content

Commit d509e7d

Browse files
matthewrankinclaude
andcommitted
Restore exported HotplugCallbackStorage type to avoid breaking change
Rename hotplugStorage back to HotplugCallbackStorage to preserve the public API for v2 consumers. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent b64c784 commit d509e7d

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

hotplug.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ type hotplugCallback struct {
5858
fn HotPlugCbFunc
5959
}
6060

61-
// hotplugStorage holds the callback map and done channel for a single context.
62-
type hotplugStorage struct {
61+
// HotplugCallbackStorage holds the callback map and done channel for a single
62+
// context.
63+
type HotplugCallbackStorage struct {
6364
callbackMap map[uint32]hotplugCallback
6465
done chan struct{}
6566
mu sync.RWMutex
@@ -73,20 +74,20 @@ const hotplugEventTimeoutMs = 200
7374
// hotplugRegistry maps context pointers to their hotplug storage, allowing
7475
// multiple contexts to register hotplug callbacks independently.
7576
var (
76-
hotplugRegistry = make(map[*C.libusb_context]*hotplugStorage)
77+
hotplugRegistry = make(map[*C.libusb_context]*HotplugCallbackStorage)
7778
hotplugRegistryMu sync.RWMutex
7879
)
7980

8081
func getHotplugStorage(
8182
libCtx *C.libusb_context,
82-
) *hotplugStorage {
83+
) *HotplugCallbackStorage {
8384
hotplugRegistryMu.RLock()
8485
defer hotplugRegistryMu.RUnlock()
8586
return hotplugRegistry[libCtx]
8687
}
8788

88-
func (ctx *Context) newHotPlugHandler() *hotplugStorage {
89-
storage := &hotplugStorage{
89+
func (ctx *Context) newHotPlugHandler() *HotplugCallbackStorage {
90+
storage := &HotplugCallbackStorage{
9091
callbackMap: make(map[uint32]hotplugCallback),
9192
done: make(chan struct{}),
9293
}
@@ -99,7 +100,7 @@ func (ctx *Context) newHotPlugHandler() *hotplugStorage {
99100
return storage
100101
}
101102

102-
func (ctx *Context) getOrCreateHotplugStorage() *hotplugStorage {
103+
func (ctx *Context) getOrCreateHotplugStorage() *HotplugCallbackStorage {
103104
storage := getHotplugStorage(ctx.libusbContext)
104105
if storage == nil {
105106
storage = ctx.newHotPlugHandler()
@@ -253,7 +254,7 @@ func (ctx *Context) hotplugHandleEventsCompleteAll() {
253254
removeHotplugStorage(ctx.libusbContext)
254255
}
255256

256-
func (storage *hotplugStorage) handleEvents(
257+
func (storage *HotplugCallbackStorage) handleEvents(
257258
libCtx *C.libusb_context,
258259
) {
259260
for {

0 commit comments

Comments
 (0)