github.com/cyverse/go-irodsclient@v0.13.2/irods/message/read_data_object_response.go (about) 1 package message 2 3 import ( 4 "github.com/cyverse/go-irodsclient/irods/common" 5 "github.com/cyverse/go-irodsclient/irods/types" 6 "golang.org/x/xerrors" 7 ) 8 9 // IRODSMessageReadDataObjectResponse stores data object read response 10 type IRODSMessageReadDataObjectResponse struct { 11 // empty structure 12 Result int 13 Data []byte 14 } 15 16 // CheckError returns error if server returned an error 17 func (msg *IRODSMessageReadDataObjectResponse) CheckError() error { 18 if msg.Result < 0 { 19 return types.NewIRODSError(common.ErrorCode(msg.Result)) 20 } 21 return nil 22 } 23 24 // FromMessage returns struct from IRODSMessage 25 func (msg *IRODSMessageReadDataObjectResponse) FromMessage(msgIn *IRODSMessage) error { 26 if msgIn.Body == nil { 27 return xerrors.Errorf("empty message body") 28 } 29 30 msg.Result = int(msgIn.Body.IntInfo) 31 msg.Data = msgIn.Body.Bs 32 return nil 33 }