fs: remove unnecessary type parameters where inference works
Go can infer [HandlerCtx] from function argument types. Only DirNode needs explicit type parameter since its args are ...any.
This commit is contained in:
parent
ae6b833d1e
commit
19e255c869
|
|
@ -103,42 +103,42 @@ func DirNode(name string, args ...any) FsNodeDecl {
|
|||
|
||||
// Each declares a directory that is instantiated for each binding in a collection.
|
||||
func Each(name string, bindings func(HandlerCtx) ([]Binding, error), args ...any) FsNodeDecl {
|
||||
return fsedsl.Each[HandlerCtx](name, bindings, args...)
|
||||
return fsedsl.Each(name, bindings, args...)
|
||||
}
|
||||
|
||||
// FileNode declares a file node (non-directory).
|
||||
func FileNode(name string, mode os.FileMode, opts ...NodeOption) FsNodeDecl {
|
||||
return fsedsl.FileNode[HandlerCtx](name, mode, opts...)
|
||||
return fsedsl.FileNode(name, mode, opts...)
|
||||
}
|
||||
|
||||
// ── Options ──────────────────────────────────────────────────────
|
||||
|
||||
func Read(fn func(HandlerCtx) ([]byte, error)) NodeOption {
|
||||
return fsedsl.Read[HandlerCtx](fn)
|
||||
return fsedsl.Read(fn)
|
||||
}
|
||||
|
||||
func Write(fn func(HandlerCtx, []byte) error) NodeOption {
|
||||
return fsedsl.Write[HandlerCtx](fn)
|
||||
return fsedsl.Write(fn)
|
||||
}
|
||||
|
||||
func Stream(fn func(HandlerCtx, context.Context, string) ([]byte, string, error)) NodeOption {
|
||||
return fsedsl.Stream[HandlerCtx](fn)
|
||||
return fsedsl.Stream(fn)
|
||||
}
|
||||
|
||||
func BlockOnce(fn func(HandlerCtx, context.Context, string) ([]byte, string, error)) NodeOption {
|
||||
return fsedsl.BlockOnce[HandlerCtx](fn)
|
||||
return fsedsl.BlockOnce(fn)
|
||||
}
|
||||
|
||||
func Request(fn func(HandlerCtx, []byte) ([]byte, error)) NodeOption {
|
||||
return fsedsl.Request[HandlerCtx](fn)
|
||||
return fsedsl.Request(fn)
|
||||
}
|
||||
|
||||
func CreateFile(fn func(HandlerCtx, string) error) NodeOption {
|
||||
return fsedsl.CreateFile[HandlerCtx](fn)
|
||||
return fsedsl.CreateFile(fn)
|
||||
}
|
||||
|
||||
func Remove(fn func(HandlerCtx) error) NodeOption {
|
||||
return fsedsl.RemoveNode[HandlerCtx](fn)
|
||||
return fsedsl.RemoveNode(fn)
|
||||
}
|
||||
|
||||
func Stat(fn func() os.FileInfo) NodeOption {
|
||||
|
|
|
|||
Loading…
Reference in New Issue