//go:build ignore

package main

func ListenAndServe(addr string, filesystem fs.FS) error {
	styx.HandlerFunc(func(s *styx.Session) {
		for s.Next() {
			switch msg := s.Request.(type) {
			case styx.Twalk:
				msg.Rwalk(fs.Stat(filesystem, msg.Path()))
			case styx.Topen:
				msg.Ropen(filesystem.Open(msg.Path()))
			case styx.Tstat:
				msg.Rstat(fs.Stat(filesystem, msg.Path()))
			}
		}
	},
	)
}

type FS struct {
	meshFile
}

type meshFile struct {
}

type meshFileInfo struct {
	bufio.Reader
	time.Time
}

func (f meshFileInfo) Name() string       { return "mesh" }
func (f meshFileInfo) Size() int64        { return f.Reader.Size() }
func (f meshFileInfo) Mode() fs.FileMode  { return fs.ModePerm }
func (f meshFileInfo) ModTime() time.Time { return f.Time }
func (f meshFileInfo) IsDir() bool        { return false }
func (f meshFileInfo) Sys() any           { return nil }

func (f meshFile) Stat() (fs.FileInfo, error) {
}
