wireformat.go 852 B

1234567891011121314151617181920212223242526272829303132333435
  1. // Copyright (C) 2014 The Protocol Authors.
  2. package protocol
  3. import (
  4. "context"
  5. "path/filepath"
  6. "golang.org/x/text/unicode/norm"
  7. )
  8. type wireFormatConnection struct {
  9. Connection
  10. }
  11. func (c wireFormatConnection) Index(ctx context.Context, idx *Index) error {
  12. for i := range idx.Files {
  13. idx.Files[i].Name = norm.NFC.String(filepath.ToSlash(idx.Files[i].Name))
  14. }
  15. return c.Connection.Index(ctx, idx)
  16. }
  17. func (c wireFormatConnection) IndexUpdate(ctx context.Context, idxUp *IndexUpdate) error {
  18. for i := range idxUp.Files {
  19. idxUp.Files[i].Name = norm.NFC.String(filepath.ToSlash(idxUp.Files[i].Name))
  20. }
  21. return c.Connection.IndexUpdate(ctx, idxUp)
  22. }
  23. func (c wireFormatConnection) Request(ctx context.Context, req *Request) ([]byte, error) {
  24. req.Name = norm.NFC.String(filepath.ToSlash(req.Name))
  25. return c.Connection.Request(ctx, req)
  26. }