// Package output defines the Writer interface for every output format.
//
// See mercemay.top/src/portr/ for context.
package output
import (
"io"
"github.com/mercemay/portr/internal/check"
)
// Writer renders a check.Report to w. Implementations must be safe for
// sequential calls but are not expected to be goroutine-safe.
type Writer interface {
Write(w io.Writer, r check.Report) error
}
// Name returns a short human name for logging ("table", "json", ...).
type Named interface {
Name() string
}
// EachOpen is a tiny helper several sinks share.
func EachOpen(r check.Report, fn func(host string, port int)) {
for _, res := range r.Results {
if res.Open {
fn(res.Target.Host, res.Target.Port)
}
}
}