package onecontext

import (
	
	
)

// DetachedContext holds the logic to detach a cancellation signal from a context.
type DetachedContext struct {
	ctx    context.Context
	ch     chan struct{}
	cancel func()
}

// Detach detaches the cancellation signal from a context.
func ( context.Context) (*DetachedContext, func()) {
	 := make(chan struct{})
	 := func() {
		close()
	}
	return &DetachedContext{
		ctx:    ,
		ch:     ,
		cancel: ,
	}, 
}

// Deadline returns a nil deadline.
func ( *DetachedContext) () (time.Time, bool) {
	return time.Time{}, false
}

// Done returns a cancellation signal that expires only when the context is canceled from the cancel function returned in Detach.
func ( *DetachedContext) () <-chan struct{} {
	return .ch
}

// Err returns an error if the context is canceled from the cancel function returned in Detach.
func ( *DetachedContext) () error {
	select {
	case <-.Done():
		return ErrCanceled
	default:
		return nil
	}
}

// Value returns the value associated with the key from the original context.
func ( *DetachedContext) ( interface{}) interface{} {
	return .ctx.Value()
}