add embeddable scanner SDK

This commit is contained in:
ZacharyZcR
2026-05-18 14:41:15 +08:00
parent bce0a718ea
commit 6bfa05cb45
8 changed files with 515 additions and 2 deletions
+17
View File
@@ -17,6 +17,23 @@ func SetResultCallback(cb ResultCallback) {
resultCallback = cb
}
// ReplaceResultCallback temporarily replaces the result callback and returns a
// restore function. This is useful for embedded callers that need to collect
// structured results without permanently stealing the callback from another
// subsystem.
func ReplaceResultCallback(cb ResultCallback) func() {
callbackMu.Lock()
previous := resultCallback
resultCallback = cb
callbackMu.Unlock()
return func() {
callbackMu.Lock()
resultCallback = previous
callbackMu.Unlock()
}
}
// NotifyResult 通知结果给回调函数
func NotifyResult(result interface{}) {
callbackMu.RLock()
+10
View File
@@ -88,3 +88,13 @@ func CloseLogger() {
globalLogger.Close()
}
}
// ResetLogger clears the process-wide logger so embedded callers can rebuild it
// after replacing runtime configuration.
func ResetLogger() {
if globalLogger != nil {
globalLogger.Close()
}
globalLogger = nil
loggerOnce = sync.Once{}
}