github.com/minio/simdjson-go@v0.4.6-0.20231116094823-04d21cddf993/simdjson_other.go (about)

     1  //go:build !amd64 || appengine || !gc || noasm
     2  // +build !amd64 appengine !gc noasm
     3  
     4  /*
     5   * MinIO Cloud Storage, (C) 2020 MinIO, Inc.
     6   *
     7   * Licensed under the Apache License, Version 2.0 (the "License");
     8   * you may not use this file except in compliance with the License.
     9   * You may obtain a copy of the License at
    10   *
    11   *     http://www.apache.org/licenses/LICENSE-2.0
    12   *
    13   * Unless required by applicable law or agreed to in writing, software
    14   * distributed under the License is distributed on an "AS IS" BASIS,
    15   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    16   * See the License for the specific language governing permissions and
    17   * limitations under the License.
    18   */
    19  
    20  package simdjson
    21  
    22  import (
    23  	"errors"
    24  	"fmt"
    25  	"io"
    26  )
    27  
    28  // SupportedCPU will return whether the CPU is supported.
    29  func SupportedCPU() bool {
    30  	return false
    31  }
    32  
    33  // Parse an object or array from a block of data and return the parsed JSON.
    34  // An optional block of previously parsed json can be supplied to reduce allocations.
    35  func Parse(b []byte, reuse *ParsedJson, opts ...ParserOption) (*ParsedJson, error) {
    36  	return nil, errors.New("Unsupported platform")
    37  }
    38  
    39  // ParseND will parse newline delimited JSON objects or arrays.
    40  // An optional block of previously parsed json can be supplied to reduce allocations.
    41  func ParseND(b []byte, reuse *ParsedJson, opts ...ParserOption) (*ParsedJson, error) {
    42  	return nil, errors.New("Unsupported platform")
    43  }
    44  
    45  // A Stream is used to stream back results.
    46  // Either Error or Value will be set on returned results.
    47  type Stream struct {
    48  	Value *ParsedJson
    49  	Error error
    50  }
    51  
    52  // ParseNDStream will parse a stream and return parsed JSON to the supplied result channel.
    53  // The method will return immediately.
    54  // Each element is contained within a root tag.
    55  //
    56  //	<root>Element 1</root><root>Element 2</root>...
    57  //
    58  // Each result will contain an unspecified number of full elements,
    59  // so it can be assumed that each result starts and ends with a root tag.
    60  // The parser will keep parsing until writes to the result stream blocks.
    61  // A stream is finished when a non-nil Error is returned.
    62  // If the stream was parsed until the end the Error value will be io.EOF
    63  // The channel will be closed after an error has been returned.
    64  // An optional channel for returning consumed results can be provided.
    65  // There is no guarantee that elements will be consumed, so always use
    66  // non-blocking writes to the reuse channel.
    67  func ParseNDStream(r io.Reader, res chan<- Stream, reuse <-chan *ParsedJson) {
    68  	go func() {
    69  		res <- Stream{
    70  			Value: nil,
    71  			Error: fmt.Errorf("Unsupported platform"),
    72  		}
    73  		close(res)
    74  	}()
    75  	return
    76  }