• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

thanos / codecs / ae978b71ff7c58bc37af1735306ab7032d8261d2-PR-47

18 Jul 2026 07:20PM UTC coverage: 95.392% (-3.3%) from 98.7%
ae978b71ff7c58bc37af1735306ab7032d8261d2-PR-47

Pull #47

github

thanos
fixed formatting
Pull Request #47: V0.2.3/spatial streaming

622 of 674 new or added lines in 12 files covered. (92.28%)

3 existing lines in 3 files now uncovered.

1242 of 1302 relevant lines covered (95.39%)

539.14 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

72.73
/lib/ex_codecs/spatial/codec/stream_source.ex
1
defmodule ExCodecs.Spatial.Codec.StreamSource do
2
  @moduledoc false
3

4
  # Shared `:source` resolution for spatial stream_decode paths.
5
  # Default is `:binary`; `:file` and `:auto` are explicit opt-ins.
6

7
  alias ExCodecs.Spatial.Accel
8

9
  @type codec :: :spatial_binary | :gsplat | :ply
10
  @type resolved :: {:ok, :binary | :file, binary()} | {:error, ExCodecs.Error.t()}
11

12
  @spec resolve(binary(), keyword(), codec(), (binary() -> boolean())) :: resolved()
13
  def resolve(bin, opts, codec, path_like?)
14
      when is_binary(bin) and is_function(path_like?, 1) and
15
             codec in [:spatial_binary, :gsplat, :ply] do
16
    case Keyword.get(opts, :source, :binary) do
202✔
17
      :binary ->
18
        {:ok, :binary, bin}
28✔
19

20
      :file ->
21
        {:ok, :file, bin}
173✔
22

23
      :auto ->
24
        if path_like?.(bin) and File.regular?(bin) do
1✔
25
          {:ok, :file, bin}
1✔
26
        else
NEW
27
          {:ok, :binary, bin}
×
28
        end
29

NEW
30
      other ->
×
31
        {:error,
32
         ExCodecs.Error.new(:invalid_options,
33
           codec: codec,
34
           message: "Unsupported :source #{inspect(other)}; use :binary, :file, or :auto"
35
         )}
36
    end
37
  end
38

39
  @spec path_like?(binary(), (binary() -> boolean()), [String.t()]) :: boolean()
40
  def path_like?(bin, magic?, extensions)
41
      when is_binary(bin) and is_function(magic?, 1) and is_list(extensions) do
42
    byte_size(bin) < 4096 and not magic?.(bin) and
1✔
43
      (String.contains?(bin, "/") or String.contains?(bin, "\\") or
1✔
NEW
44
         String.ends_with?(bin, extensions))
×
45
  end
46

47
  @spec accel?(keyword()) :: boolean()
48
  def accel?(opts) when is_list(opts) do
49
    Keyword.get(opts, :accel, true) != false and Accel.available?()
1,666✔
50
  end
51
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc