Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ListSerializer ¶
type ListSerializer[T cmp.Ordered] interface { Serialize(writer io.Writer, vertices []*dag.Vertex[T]) error }
ListSerializer is an interface that defines a method to create a serializable object from a vertex.
type ListSerializerFunc ¶
ListSerializerFunc is a function type that implements the ListSerializer interface.
type Renderer ¶
Renderer renders a tree from a DirectedAcyclicGraph as a flat last in a particular output format. The output rendered by the Renderer with OutputFormatJSON looks like this:
[ "A", "B", "C", "D" ]
The output is analogous to a tree structure, but without the indentation.
── A ├─ B │ ╰─ C ╰─ D
Each letter corresponds to a vertex in the DirectedAcyclicGraph. The concrete representation of the vertex is defined by the ListSerializer.
func New ¶
func New[T cmp.Ordered](ctx context.Context, graph *syncdag.SyncedDirectedAcyclicGraph[T], opts ...RendererOption[T]) *Renderer[T]
New creates a new Renderer for the given DirectedAcyclicGraph.
type RendererOption ¶
type RendererOption[T cmp.Ordered] func(*RendererOptions[T])
RendererOption is a function that modifies the RendererOptions.
func WithListSerializer ¶
func WithListSerializer[T cmp.Ordered](serializer ListSerializer[T]) RendererOption[T]
WithListSerializer sets the ListSerializer for the Renderer.
func WithListSerializerFunc ¶
func WithListSerializerFunc[T cmp.Ordered](serializerFunc func(writer io.Writer, vertices []*dag.Vertex[T]) error) RendererOption[T]
WithListSerializerFunc sets the ListSerializer based on a function.
func WithRoots ¶
func WithRoots[T cmp.Ordered](roots ...T) RendererOption[T]
WithRoots sets the roots for the Renderer.
type RendererOptions ¶
type RendererOptions[T cmp.Ordered] struct { // The ListSerializer converts a vertex to an object that is expected to // be a serializable type (e.g., a struct or map). The ListSerializer MUST // perform READ-ONLY access to the vertex and its attributes. ListSerializer ListSerializer[T] // Roots are the root vertices of the list to render. Roots []T }
RendererOptions defines the options for the list Renderer.
type Serializer ¶
type Serializer[T cmp.Ordered] struct { // VertexSerializer is a function that converts a vertex to an object // that can be serialized to JSON. VertexSerializer VertexSerializer[T] // OutputFormat specifies the format in which the output should be rendered. // Serializer supports JSON, NDJSON, and YAML formats. OutputFormat render.OutputFormat }
Serializer implements the ListSerializer interface for serializing a slice of vertices to a set of output formats.
func NewSerializer ¶
func NewSerializer[T cmp.Ordered](opts ...SerializerOption[T]) Serializer[T]
type SerializerOption ¶
type SerializerOption[T cmp.Ordered] func(*Serializer[T])
SerializerOption is a function that modifies the SerializerOptions.
func WithOutputFormat ¶
func WithOutputFormat[T cmp.Ordered](format render.OutputFormat) SerializerOption[T]
WithOutputFormat sets the output format for the Serializer.
func WithVertexSerializer ¶
func WithVertexSerializer[T cmp.Ordered](serializer VertexSerializer[T]) SerializerOption[T]
WithVertexSerializer sets the VertexSerializer for the Renderer.
func WithVertexSerializerFunc ¶
func WithVertexSerializerFunc[T cmp.Ordered](serializerFunc func(vertex *dag.Vertex[T]) (any, error)) SerializerOption[T]
WithVertexSerializerFunc sets the VertexSerializer based on a function.
type VertexSerializer ¶
type VertexSerializerFunc ¶
VertexSerializerFunc is a function type that implements the VertexSerializer interface.