go-hep.org/x/hep@v0.38.1/xrootd/xrdproto/sync/sync.go (about)

     1  // Copyright ©2018 The go-hep Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // Package sync contains the structures describing sync request.
     6  // See xrootd protocol specification (http://xrootd.org/doc/dev45/XRdv310.pdf, p. 119) for details.
     7  package sync // import "go-hep.org/x/hep/xrootd/xrdproto/sync"
     8  
     9  import (
    10  	"go-hep.org/x/hep/xrootd/internal/xrdenc"
    11  	"go-hep.org/x/hep/xrootd/xrdfs"
    12  )
    13  
    14  // RequestID is the id of the request, it is sent as part of message.
    15  // See xrootd protocol specification for details: http://xrootd.org/doc/dev45/XRdv310.pdf, 2.3 Client Request Format.
    16  const RequestID uint16 = 3016
    17  
    18  // Request holds sync request parameters, such as the file handle.
    19  type Request struct {
    20  	Handle xrdfs.FileHandle
    21  	_      [12]byte
    22  	_      int32
    23  }
    24  
    25  // MarshalXrd implements xrdproto.Marshaler.
    26  func (o Request) MarshalXrd(wBuffer *xrdenc.WBuffer) error {
    27  	wBuffer.WriteBytes(o.Handle[:])
    28  	wBuffer.Next(16)
    29  	return nil
    30  }
    31  
    32  // UnmarshalXrd implements xrdproto.Unmarshaler.
    33  func (o *Request) UnmarshalXrd(rBuffer *xrdenc.RBuffer) error {
    34  	rBuffer.ReadBytes(o.Handle[:])
    35  	rBuffer.Skip(16)
    36  	return nil
    37  }
    38  
    39  // ReqID implements xrdproto.Request.ReqID.
    40  func (req *Request) ReqID() uint16 { return RequestID }
    41  
    42  // ShouldSign implements xrdproto.Request.ShouldSign.
    43  func (req *Request) ShouldSign() bool { return false }