go-hep.org/x/hep@v0.38.1/xrootd/xrdproto/xrdclose/xrdclose.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 xrdclose contains the structures describing request and response for close request. 6 // See xrootd protocol specification (http://xrootd.org/doc/dev45/XRdv310.pdf, p. 41) for details. 7 package xrdclose // import "go-hep.org/x/hep/xrootd/xrdproto/xrdclose" 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 = 3003 17 18 // Request holds close request parameters, such as 19 // the file handle and the size, in bytes, that the file 20 // is to have. The close operation fails and the file 21 // is erased if it is not of the indicated size. A size of 0 22 // suppresses the check. 23 type Request struct { 24 Handle xrdfs.FileHandle 25 Size int64 26 _ [4]byte 27 _ int32 28 } 29 30 // MarshalXrd implements xrdproto.Marshaler. 31 func (o Request) MarshalXrd(wBuffer *xrdenc.WBuffer) error { 32 wBuffer.WriteBytes(o.Handle[:]) 33 wBuffer.WriteI64(o.Size) 34 wBuffer.Next(8) 35 return nil 36 } 37 38 // UnmarshalXrd implements xrdproto.Unmarshaler. 39 func (o *Request) UnmarshalXrd(rBuffer *xrdenc.RBuffer) error { 40 rBuffer.ReadBytes(o.Handle[:]) 41 o.Size = rBuffer.ReadI64() 42 rBuffer.Skip(8) 43 return nil 44 } 45 46 // ReqID implements xrdproto.Request.ReqID. 47 func (req *Request) ReqID() uint16 { return RequestID } 48 49 // ShouldSign implements xrdproto.Request.ShouldSign. 50 func (req *Request) ShouldSign() bool { return false }