1# Old Behavior
2
3In previous versions of `exprotobuf` files that had `import "some_other.proto";` statements were automatically handled.
4This behavior has been replaced by the ability to load in a list of protobuf files when calling `use Protobuf`.
5
6## An Example
7
8Imagine we had two protobuf files.
9
10`basic.proto`
11
12```protobuf
13import "colors.proto";
14
15message Basic {
16  required uint32 id = 1;
17  optional Color color = 2;
18}
19```
20
21`colors.proto`
22
23```protobuf
24enum Color {
25  WHITE = 0;
26  BLACK = 1;
27  GRAY = 2;
28  RED = 3;
29}
30```
31
32What we would like to do with these definitions is load them into elixir and do something like:
33
34```elixir
35Test.Basic.new(id: 123, color: :RED) |> Test.Basic.encode
36# => <<8, 123, 16, 3>>
37Test.Basic.decode(<<8, 123, 16, 3>>)
38# => %Test.Basic{color: :RED, id: 123}
39```
40
41## The Old Behavior
42
43```elixir
44defmodule Test do
45  use Protobuf, from: "./test/basic.proto"
46end
47```
48
49`exprotobuf` would look for the `import "colors.proto";` statement, then try to find that
50file, parse it and copy all of its definitions into the same namespace as the Basic message.
51This required very little developer effort, but copying definitions had a few drawbacks.
52For example, if there were several different files that all used `colors.proto` they would
53each have a copy of that definition so there would be multiple elixir modules that all referenced the same enum.
54
55## The New Behavior
56
57```elixir
58defmodule Test do
59  use Protobuf, from: ["./test/basic.proto","./test/colors.proto"]
60end
61```
62
63You can now pass a list of proto files to `exprotobuf` and it will parse all of them and resolve all of their names at the same time.
64This is a little more work for the developer, but it closely mirrors the way proto files are used in other implementations of protobuf for java and python.
65If there were multiple files that all used the `Color` enum, they would all share the same definition and there will be just a single elixir module that represents that enum.
66