Skip to content

Commit

Permalink
Expose Struct() and List() methods from Future.
Browse files Browse the repository at this point in the history
  • Loading branch information
lthibault committed Nov 14, 2022
1 parent a671c94 commit 0b8e0f8
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions answer.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,15 +299,13 @@ func (ans *Answer) Done() <-chan struct{} {
// Struct waits until the answer is resolved and returns the struct
// this answer represents.
func (ans *Answer) Struct() (Struct, error) {
p, err := ans.f.Ptr()
return p.Struct(), err
return ans.f.Struct()
}

// List waits until the answer is resolved and returns the list
// this answer represents.
func (ans *Answer) List() (List, error) {
p, err := ans.f.Ptr()
return p.List(), err
return ans.f.List()
}

// Client returns the answer as a client. If the answer's originating
Expand Down Expand Up @@ -427,7 +425,7 @@ func (f *Future) Done() <-chan struct{} {
return f.promise.resolved
}

// Struct waits until the answer is resolved and returns the pointer
// Ptr waits until the answer is resolved and returns the pointer
// this future represents.
func (f *Future) Ptr() (Ptr, error) {
p := f.promise
Expand All @@ -438,6 +436,20 @@ func (f *Future) Ptr() (Ptr, error) {
return r.ptr(f.transform())
}

// Struct waits until the answer is resolved and returns the struct
// this answer represents.
func (f *Future) Struct() (Struct, error) {
p, err := f.Ptr()
return p.Struct(), err
}

// List waits until the answer is resolved and returns the list
// this answer represents.
func (f *Future) List() (List, error) {
p, err := f.Ptr()
return p.List(), err
}

// Client returns the future as a client. If the answer's originating
// call has not completed, then calls will be queued until the original
// call's completion. The client reference is borrowed: the caller
Expand Down

0 comments on commit 0b8e0f8

Please sign in to comment.