Versions in this module Expand all Collapse all v0 v0.0.1 Jan 30, 2026 Changes in this version + const Csv + const DefaultBaseTempDir + const Docx + const Jpeg + const Jpg + const Json + const KindFile + const KindMemory + const KindMultipart + const KindReader + const KindStream + const KindURL + const Pdf + const Png + const Pptx + const Txt + const Xlsx + const Xml + const Zip + var ErrCannotGetReaderAt = errors.New("fio: cannot get ReaderAt") + var ErrCannotResetInput = errors.New("fio: cannot reset input") + var ErrDownloadFailed = errors.New("fio: download failed") + var ErrEmptyPath = errors.New("fio: empty path") + var ErrEmptyURL = errors.New("fio: empty url") + var ErrFileStorageUnavailable = errors.New("fio: file storage requires directory") + var ErrInputNotReusable = errors.New("fio: input is not reusable") + var ErrInvalidSessionType = errors.New("fio: invalid session type") + var ErrIoManagerClosed = errors.New("fio: manager is closed") + var ErrIoSessionClosed = errors.New("fio: session is closed") + var ErrNewOutMultiple = errors.New("fio: NewOut called more than once") + var ErrNilFunc = errors.New("fio: fn is nil") + var ErrNilInput = errors.New("fio: nil input") + var ErrNilOutHandle = errors.New("fio: nil OutHandle") + var ErrNilOutScope = errors.New("fio: nil out-scope") + var ErrNilSource = errors.New("fio: nil source") + var ErrNoSession = errors.New("fio: session is nil") + var ErrOutReuseRequiresPtr = errors.New("fio: OutReuse requires out pointer") + var ErrOutputCleaned = errors.New("fio: output is cleaned up") + var ErrToReaderAtNilReader = errors.New("fio: ToReaderAt: nil reader") + func Configure(config Config) error + func Do[T any](ctx context.Context, fn func(s *Scope) (*T, error)) (*T, error) + func JoinCleanup(fns ...func() error) func() error + func MB(size int64) int64 + func Read(ctx context.Context, src Source, fn func(r io.Reader) error) error + func ReadAt(ctx context.Context, src Source, fn func(ra io.ReaderAt, size int64) error, ...) error + func ReadAtResult[T any](ctx context.Context, src Source, ...) (*T, error) + func ReadFileLines(ctx context.Context, path string, fn LineFunc) error + func ReadLines(ctx context.Context, src Source, fn LineFunc) error + func ReadList(ctx context.Context, srcs []Source, fn func(readers []io.Reader) error) error + func ReadListResult[T any](ctx context.Context, srcs []Source, fn func(readers []io.Reader) (*T, error)) (*T, error) + func ReadResult[T any](ctx context.Context, src Source, fn func(r io.Reader) (*T, error)) (*T, error) + func SafeClose(c io.Closer) + func Size(ctx context.Context, src Source) (int64, error) + func SizeAny(x any) int64 + func SizeFromStream(src Source) int64 + func SizeFromStreamList(srcs []Source) int64 + func ToExt(format string) string + func WithMaxPreallocate(bytes int64) maxPreallocateOption + func WithMmap(enabled bool) mmapOption + func WithSession(ctx context.Context, ses IoSession) context.Context + func WithSpillThreshold(bytes int64) spillThresholdOption + func WithThreshold(bytes int64) thresholdOption + func WriteFile(r io.Reader, path string) (int64, error) + func WriteStreamToFile(src Source, path string) (int64, error) + type Config struct + func NewConfig(client *http.Client) Config + func (c Config) WithClient(client *http.Client) Config + type DownloadReaderCloser interface + func NewDownloadReaderCloser(src Source, cleanup ...func()) (DownloadReaderCloser, error) + type InOption func(*inConfig) + func DeleteAfterUse() InOption + func Reusable() InOption + type Input struct + Kind string + Path string + Reader io.ReadCloser + Size int64 + func OpenIn(ctx context.Context, src Source, opts ...InOption) (*Input, error) + func (in *Input) Close() error + func (in *Input) IsReusable() bool + func (in *Input) ReaderAt() io.ReaderAt + func (in *Input) Reset() error + type IoManager interface + Cleanup func() error + NewSession func() (IoSession, error) + func NewIoManager(baseDir string, storageType StorageType, opts ...ManagerOption) (IoManager, error) + type IoSession interface + Cleanup func() error + NewOut func(out OutConfig, sizeHint ...int64) (*Output, error) + func Session(ctx context.Context) IoSession + type LineFunc func(line string) error + type ManagerOption interface + type ManagerOptionFunc func(*managerConfig) + type OutConfig struct + func Out(ext string, opts ...OutOption) OutConfig + func WithOut(ext string, opts ...OutOption) OutConfig + func (o OutConfig) AutoThreshold() *int64 + func (o OutConfig) Ext() string + func (o OutConfig) StorageTypeVal() *StorageType + type OutHandle struct + Writer io.WriteCloser + func NewOut(ctx context.Context, out OutConfig, sizeHint ...int64) (*OutHandle, error) + func (h *OutHandle) Cleanup() error + func (h *OutHandle) Finalize() (*Output, error) + type OutOption interface + func OutReuse(outPtr **Output, opts ...OutReuseOpt) OutOption + func WithStorage(st StorageType) OutOption + type OutOptionFunc func(*OutConfig) + type OutReuseOpt interface + func WithCleanupOld(v bool) OutReuseOpt + func WithKeepMemCap(v bool) OutReuseOpt + func WithMaxMemCap(bytes int64) OutReuseOpt + type OutReuseOptFunc func(*outReuseConfig) + type OutScope struct + func (s *OutScope) NewOut(out OutConfig, sizeHint ...int64) (io.Writer, error) + func (s *OutScope) UseReaderAt(src Source, opts ...ToReaderAtOption) (io.ReaderAt, int64, error) + func (s *OutScope) UseSized(src Source) (io.Reader, int64, error) + type Output struct + func Copy(ctx context.Context, src Source, out OutConfig) (*Output, error) + func DoOut(ctx context.Context, outCfg OutConfig, ...) (*Output, error) + func DoOutResult[T any](ctx context.Context, outCfg OutConfig, ...) (*Output, *T, error) + func Process(ctx context.Context, src Source, out OutConfig, ...) (*Output, error) + func ProcessAt(ctx context.Context, src Source, out OutConfig, ...) (*Output, error) + func ProcessAtResult[T any](ctx context.Context, src Source, out OutConfig, ...) (*Output, *T, error) + func ProcessList(ctx context.Context, srcs []Source, out OutConfig, ...) (*Output, error) + func ProcessListResult[T any](ctx context.Context, srcs []Source, out OutConfig, ...) (*Output, *T, error) + func ProcessResult[T any](ctx context.Context, src Source, out OutConfig, ...) (*Output, *T, error) + func (o *Output) Bytes() ([]byte, error) + func (o *Output) Data() []byte + func (o *Output) Keep() *Output + func (o *Output) OpenReader() (io.ReadCloser, error) + func (o *Output) OpenWriter(sizeHint ...int64) (io.WriteCloser, error) + func (o *Output) Path() string + func (o *Output) SaveAs(path string) error + func (o *Output) Size() int64 + func (o *Output) StorageType() StorageType + func (o *Output) WriteTo(w io.Writer) (int64, error) + type ReaderAtResult struct + func ToReaderAt(ctx context.Context, r io.Reader, opts ...ToReaderAtOption) (*ReaderAtResult, error) + func (r *ReaderAtResult) Cleanup() error + func (r *ReaderAtResult) ReaderAt() io.ReaderAt + func (r *ReaderAtResult) Size() int64 + func (r *ReaderAtResult) Source() string + type Scope struct + func (s *Scope) Use(src Source) (io.Reader, error) + func (s *Scope) UseReaderAt(src Source, opts ...ToReaderAtOption) (io.ReaderAt, int64, error) + func (s *Scope) UseSized(src Source) (io.Reader, int64, error) + type Source interface + func BytesSource(b []byte) Source + func FileSource(f *os.File) Source + func In(src Source, opts ...InOption) Source + func InputSource(in *Input) Source + func MultipartSource(fh *multipart.FileHeader) Source + func OutputSource(o *Output) Source + func PathSource(p string) Source + func ReadCloserSource(rc io.ReadCloser) Source + func ReaderSource(r io.Reader) Source + func URLSource(u string) Source + type StorageType int + const File + const Memory + func (s StorageType) String() string + type ToReaderAtOption func(*ToReaderAtOptions) + func WithMaxMemoryBytes(n int64) ToReaderAtOption + func WithTempDir(dir string) ToReaderAtOption + func WithTempPattern(p string) ToReaderAtOption + type ToReaderAtOptions struct + type Void struct