github.com/NVIDIA/aistore@v1.3.23-0.20240517131212-7df6609be51d/cmn/jsp/opts.go (about)

     1  // Package jsp (JSON persistence) provides utilities to store and load arbitrary
     2  // JSON-encoded structures with optional checksumming and compression.
     3  /*
     4   * Copyright (c) 2018-2023, NVIDIA CORPORATION. All rights reserved.
     5   */
     6  package jsp
     7  
     8  type (
     9  	Options struct {
    10  		// when non-zero, formatting version of the structure that's being (de)serialized
    11  		// (not to confuse with the jsp encoding version - see above)
    12  		Metaver uint32
    13  		// warn and keep loading
    14  		OldMetaverOk uint32
    15  
    16  		Compress  bool // lz4 when [version == 1 || version == 2]
    17  		Checksum  bool // xxhash when [version == 1 || version == 2]
    18  		Signature bool // when true, write 128bit prefix (of the layout shown above) at offset zero
    19  
    20  		Indent bool // Determines if the JSON should be indented. Useful for CLI config.
    21  	}
    22  	Opts interface {
    23  		JspOpts() Options
    24  	}
    25  )
    26  
    27  func Plain() Options { return Options{} }
    28  
    29  func CCSign(metaver uint32) Options {
    30  	return Options{Metaver: metaver, Compress: true, Checksum: true, Signature: true, Indent: false}
    31  }
    32  
    33  func CksumSign(metaver uint32) Options {
    34  	return Options{Metaver: metaver, Checksum: true, Signature: true}
    35  }