File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import (
11
11
"sync"
12
12
13
13
"github.com/djdv/go-filesystem-utils/internal/filesystem"
14
+ "github.com/djdv/go-filesystem-utils/internal/generic"
14
15
perrors "github.com/djdv/p9/errors"
15
16
"github.com/djdv/p9/fsimpl/templatefs"
16
17
"github.com/djdv/p9/p9"
51
52
GuestID () filesystem.ID
52
53
}
53
54
MountPoint interface {
54
- FieldParser
55
55
SystemMaker
56
56
Mounter
57
57
HostIdentifier
@@ -228,11 +228,17 @@ func (mf *MountPointFile[MP]) parseFieldsLocked(b []byte) error {
228
228
for _ , fields := range tokenize (b ) {
229
229
switch fields .typ () {
230
230
case keyAndValue :
231
- var (
232
- key , value = fields [key ], fields [value ]
233
- mountPoint = mf .mountPoint
234
- )
235
- if err := mountPoint .ParseField (key , value ); err != nil {
231
+ parser , ok := any (mf .mountPoint ).(FieldParser )
232
+ if ! ok {
233
+ // TODO: [Go 1.21] use [errors.ErrUnsupported].
234
+ const unsupported = generic .ConstError ("unsupported operation" )
235
+ return fmt .Errorf (
236
+ "%w - %w: %T does not implement field parser" ,
237
+ perrors .EINVAL , unsupported , mf .mountPoint ,
238
+ )
239
+ }
240
+ key , value := fields [key ], fields [value ]
241
+ if err := parser .ParseField (key , value ); err != nil {
236
242
return errors .Join (perrors .EINVAL , err )
237
243
}
238
244
mf .modified = true
You can’t perform that action at this time.
0 commit comments