diff options
| author | Matthias Radestock <matthias@lshift.net> | 2010-01-27 18:29:45 +0000 |
|---|---|---|
| committer | Matthias Radestock <matthias@lshift.net> | 2010-01-27 18:29:45 +0000 |
| commit | 340b9dab1e3fb9a03c7addba549a04472e705750 (patch) | |
| tree | c0608c007d6a582bd017113d83d4b57c72c43a71 /src | |
| parent | e4f81545eb5ed120a85b4c8737e05568bfb641ef (diff) | |
| download | rabbitmq-server-git-340b9dab1e3fb9a03c7addba549a04472e705750.tar.gz | |
flesh out binary_generator API
...for symmetry with binary_parser and because we need it in bug 21673
Diffstat (limited to 'src')
| -rw-r--r-- | src/rabbit_binary_generator.erl | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/rabbit_binary_generator.erl b/src/rabbit_binary_generator.erl index 9bffe87e55..b8e161a6bd 100644 --- a/src/rabbit_binary_generator.erl +++ b/src/rabbit_binary_generator.erl @@ -46,6 +46,7 @@ build_heartbeat_frame/0]). -export([generate_table/1, encode_properties/2]). -export([check_empty_content_body_frame_size/0]). +-export([ensure_content_encoded/1, clear_encoded_content/1]). -import(lists). @@ -63,6 +64,8 @@ -spec(generate_table/1 :: (amqp_table()) -> binary()). -spec(encode_properties/2 :: ([amqp_property_type()], [any()]) -> binary()). -spec(check_empty_content_body_frame_size/0 :: () -> 'ok'). +-spec(ensure_content_encoded/1 :: (content()) -> encoded_content()). +-spec(clear_encoded_content/1 :: (content()) -> unencoded_content()). -endif. @@ -262,3 +265,19 @@ check_empty_content_body_frame_size() -> exit({incorrect_empty_content_body_frame_size, ComputedSize, ?EMPTY_CONTENT_BODY_FRAME_SIZE}) end. + +ensure_content_encoded(Content = #content{properties_bin = PropsBin}) + when PropsBin =/= 'none' -> + Content; +ensure_content_encoded(Content = #content{properties = Props}) -> + Content #content{properties_bin = rabbit_framing:encode_properties(Props)}. + +clear_encoded_content(Content = #content{properties_bin = none}) -> + Content; +clear_encoded_content(Content = #content{properties = none}) -> + %% Only clear when we can rebuild the properties_bin later in + %% accordance to the content record definition comment - maximum + %% one of properties and properties_bin can be 'none' + Content; +clear_encoded_content(Content = #content{}) -> + Content#content{properties_bin = none}. |
