Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide path for getting sizes on directory iteration #60

Merged
merged 1 commit into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions iter/iter.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@
if itr.transformName != nil {
name = itr.transformName(name)
}
return name, next.FieldHash(), nil
return name, &IterLink{next}, nil
}
nb := dagpb.Type.String.NewBuilder()
err = nb.AssignString("")
if err != nil {
return nil, nil, err
}
s := nb.Build()
return s, next.FieldHash(), nil
return s, &IterLink{next}, nil

Check warning on line 48 in iter/iter.go

View check run for this annotation

Codecov / codecov/patch

iter/iter.go#L48

Added line #L48 was not covered by tests
}

func (itr *UnixFSDir__MapItr) Done() bool {
Expand Down
67 changes: 67 additions & 0 deletions iter/iterlink.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package iter

import (
dagpb "github.com/ipld/go-codec-dagpb"
"github.com/ipld/go-ipld-prime/datamodel"
basicnode "github.com/ipld/go-ipld-prime/node/basic"
)

type IterLink struct {
Substrate dagpb.PBLink
}

func (il *IterLink) AsBool() (bool, error) {
return false, datamodel.ErrWrongKind{}

Check warning on line 14 in iter/iterlink.go

View check run for this annotation

Codecov / codecov/patch

iter/iterlink.go#L13-L14

Added lines #L13 - L14 were not covered by tests
}
func (il *IterLink) AsBytes() ([]byte, error) {
return nil, datamodel.ErrWrongKind{}

Check warning on line 17 in iter/iterlink.go

View check run for this annotation

Codecov / codecov/patch

iter/iterlink.go#L16-L17

Added lines #L16 - L17 were not covered by tests
}
func (il *IterLink) AsFloat() (float64, error) {
return 0.0, datamodel.ErrWrongKind{}

Check warning on line 20 in iter/iterlink.go

View check run for this annotation

Codecov / codecov/patch

iter/iterlink.go#L19-L20

Added lines #L19 - L20 were not covered by tests
}
func (il *IterLink) AsInt() (int64, error) {
return 0, datamodel.ErrWrongKind{}

Check warning on line 23 in iter/iterlink.go

View check run for this annotation

Codecov / codecov/patch

iter/iterlink.go#L22-L23

Added lines #L22 - L23 were not covered by tests
}
func (il *IterLink) AsLink() (datamodel.Link, error) {
return il.Substrate.FieldHash().AsLink()
}
func (il *IterLink) AsString() (string, error) {
return "", datamodel.ErrWrongKind{}

Check warning on line 29 in iter/iterlink.go

View check run for this annotation

Codecov / codecov/patch

iter/iterlink.go#L28-L29

Added lines #L28 - L29 were not covered by tests
}

func (il *IterLink) IsAbsent() bool {
return il.Substrate.IsAbsent()

Check warning on line 33 in iter/iterlink.go

View check run for this annotation

Codecov / codecov/patch

iter/iterlink.go#L32-L33

Added lines #L32 - L33 were not covered by tests
}
func (il *IterLink) IsNull() bool {
return il.Substrate.IsNull()

Check warning on line 36 in iter/iterlink.go

View check run for this annotation

Codecov / codecov/patch

iter/iterlink.go#L35-L36

Added lines #L35 - L36 were not covered by tests
}
func (il *IterLink) Kind() datamodel.Kind {
return datamodel.Kind_Link
}
func (il *IterLink) Length() int64 {
return 0

Check warning on line 42 in iter/iterlink.go

View check run for this annotation

Codecov / codecov/patch

iter/iterlink.go#L41-L42

Added lines #L41 - L42 were not covered by tests
}
func (il *IterLink) ListIterator() datamodel.ListIterator {
return nil

Check warning on line 45 in iter/iterlink.go

View check run for this annotation

Codecov / codecov/patch

iter/iterlink.go#L44-L45

Added lines #L44 - L45 were not covered by tests
}
func (il *IterLink) LookupByIndex(idx int64) (datamodel.Node, error) {
return nil, datamodel.ErrWrongKind{}

Check warning on line 48 in iter/iterlink.go

View check run for this annotation

Codecov / codecov/patch

iter/iterlink.go#L47-L48

Added lines #L47 - L48 were not covered by tests
}
func (il *IterLink) LookupByNode(key datamodel.Node) (datamodel.Node, error) {
return nil, datamodel.ErrWrongKind{}

Check warning on line 51 in iter/iterlink.go

View check run for this annotation

Codecov / codecov/patch

iter/iterlink.go#L50-L51

Added lines #L50 - L51 were not covered by tests
}
func (il *IterLink) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error) {
return nil, datamodel.ErrWrongKind{}

Check warning on line 54 in iter/iterlink.go

View check run for this annotation

Codecov / codecov/patch

iter/iterlink.go#L53-L54

Added lines #L53 - L54 were not covered by tests
}
func (il *IterLink) LookupByString(key string) (datamodel.Node, error) {
return nil, datamodel.ErrWrongKind{}

Check warning on line 57 in iter/iterlink.go

View check run for this annotation

Codecov / codecov/patch

iter/iterlink.go#L56-L57

Added lines #L56 - L57 were not covered by tests
}
func (il *IterLink) MapIterator() datamodel.MapIterator {
return nil

Check warning on line 60 in iter/iterlink.go

View check run for this annotation

Codecov / codecov/patch

iter/iterlink.go#L59-L60

Added lines #L59 - L60 were not covered by tests
}
func (il *IterLink) Prototype() datamodel.NodePrototype {
return basicnode.Prototype__Link{}

Check warning on line 63 in iter/iterlink.go

View check run for this annotation

Codecov / codecov/patch

iter/iterlink.go#L62-L63

Added lines #L62 - L63 were not covered by tests
}
func (il *IterLink) Representation() datamodel.Node {
return il

Check warning on line 66 in iter/iterlink.go

View check run for this annotation

Codecov / codecov/patch

iter/iterlink.go#L65-L66

Added lines #L65 - L66 were not covered by tests
}