github.com/cyverse/go-irodsclient@v0.13.2/irods/message/lock_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  // IRODSMessageLockDataObjectResponse stores data object lock response
    10  type IRODSMessageLockDataObjectResponse struct {
    11  	// empty structure
    12  	FileDescriptor int
    13  }
    14  
    15  // CheckError returns error if server returned an error
    16  func (msg *IRODSMessageLockDataObjectResponse) CheckError() error {
    17  	if msg.FileDescriptor < 0 {
    18  		return types.NewIRODSError(common.ErrorCode(msg.FileDescriptor))
    19  	}
    20  	return nil
    21  }
    22  
    23  // GetFileDescriptor returns file descriptor
    24  func (msg *IRODSMessageLockDataObjectResponse) GetFileDescriptor() int {
    25  	return msg.FileDescriptor
    26  }
    27  
    28  // FromMessage returns struct from IRODSMessage
    29  func (msg *IRODSMessageLockDataObjectResponse) FromMessage(msgIn *IRODSMessage) error {
    30  	if msgIn.Body == nil {
    31  		return xerrors.Errorf("empty message body")
    32  	}
    33  
    34  	msg.FileDescriptor = int(msgIn.Body.IntInfo)
    35  	return nil
    36  }