{"modulePath":"github.com/data-preservation-programs/singularity","version":"v1.0.0","isLatest":true,"isStandardLibrary":false,"goos":"linux","goarch":"amd64","docs":"# package pack\n\n## Variables\n\n```go\nvar ErrFileModified = errors.New(\"file has been modified\")\n```\n\n```go\nvar ErrNoContent = errors.New(\"no content to pack\")\n```\n\n## Functions\n\n```go\nfunc GetCommp(calc *commp.Calc, targetPieceSize uint64) (cid.Cid, uint64, error)\n```\nGetCommp calculates the data commitment (CommP) and the piece size based on the provided commp.Calc instance and target piece size. It ensures that the calculated piece size matches the target piece size specified. If necessary, it pads the data to meet the target piece size.\n\nParameters:\n\n  - calc: A pointer to a commp.Calc instance, which has been used to write data and will be used to calculate the piece commitment for that data.\n  - targetPieceSize: The desired size of the piece, specified in bytes.\n\nReturns:\n\n  - cid.Cid: A CID (Content Identifier) representing the data commitment (CommP).\n  - uint64: The size of the piece, in bytes, after potential padding.\n  - error: An error indicating issues during the piece commitment calculation, padding, or CID conversion, or nil if the operation was successful.\n\n```go\nfunc Pack(\n\tctx context.Context,\n\tdb *gorm.DB,\n\tjob model.Job,\n) (*model.Car, error)\n```\nPack takes in a Job and processes its attachment by reading it, possibly encrypting it, splitting it into manageable chunks, and then storing those chunks into a designated storage. If the job's attachment requires encryption, it will be encrypted using the specified encryption method. The function returns a slice of Car objects which represent the stored chunks and an error if any occurred.\n\nParameters:\n\n  - ctx: The context which controls the lifetime of the operation.\n  - db: The gorm database instance used for querying and updating database records.\n  - job: The Job model instance which contains information about the attachment to be processed.\n\nReturns:\n\n  - A slice of model.Car instances representing stored chunks.\n  - An error, if any occurred during the operation.\n\n## Types\n\n```go\ntype Assembler struct {\n\t// contains filtered or unexported fields\n}\n```\nAssembler assembles various objects and data streams into a coherent output stream. It uses the provided file ranges, and internal buffers to produce the desired output.\n\n```go\nfunc NewAssembler(ctx context.Context, reader storagesystem.Reader,\n\tfileRanges []model.FileRange, noInline bool, skipInaccessibleFiles bool,\n) *Assembler\n```\nNewAssembler initializes a new Assembler instance with the given parameters.\n\n```go\nfunc (a *Assembler) Close() error\n```\nClose closes the assembler and all of its underlying readers\n\n```go\nfunc (a *Assembler) Read(p []byte) (int, error)\n```\nRead reads data from the buffer, or fetches the next chunk from fileRanges if the buffer is empty. It will assemble links if needed and respect the context's cancellation or deadline.\n\n","path":"github.com/data-preservation-programs/singularity/pack","name":"pack","synopsis":"","isRedistributable":true}
