| 1 |
|
%% Copyright (c) 2022 Peter Morgan <peter.james.morgan@gmail.com> |
| 2 |
|
%% |
| 3 |
|
%% Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 |
|
%% you may not use this file except in compliance with the License. |
| 5 |
|
%% You may obtain a copy of the License at |
| 6 |
|
%% |
| 7 |
|
%% http://www.apache.org/licenses/LICENSE-2.0 |
| 8 |
|
%% |
| 9 |
|
%% Unless required by applicable law or agreed to in writing, software |
| 10 |
|
%% distributed under the License is distributed on an "AS IS" BASIS, |
| 11 |
|
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 |
|
%% See the License for the specific language governing permissions and |
| 13 |
|
%% limitations under the License. |
| 14 |
|
|
| 15 |
|
|
| 16 |
|
-module(mcd_statem). |
| 17 |
|
|
| 18 |
|
|
| 19 |
|
-export([nei/1]). |
| 20 |
|
-export([send_request/1]). |
| 21 |
|
|
| 22 |
|
|
| 23 |
|
-type request_id() :: gen_statem:request_id(). |
| 24 |
|
-type request_id_collection() :: gen_statem:request_id_collection(). |
| 25 |
|
-type server_ref() :: gen_statem:server_ref(). |
| 26 |
|
|
| 27 |
|
-type collection_req() :: #{server_ref := server_ref(), |
| 28 |
|
request := any(), |
| 29 |
|
label := any(), |
| 30 |
|
requests := request_id_collection()}. |
| 31 |
|
|
| 32 |
|
-type id_req() :: #{server_ref := server_ref(), |
| 33 |
|
request := any()}. |
| 34 |
|
|
| 35 |
|
-spec send_request(collection_req()) -> request_id_collection(); |
| 36 |
|
(id_req()) -> request_id(). |
| 37 |
|
|
| 38 |
|
send_request(#{server_ref := ServerRef, |
| 39 |
|
request := Request, |
| 40 |
|
label := Label, |
| 41 |
|
requests := Requests}) -> |
| 42 |
:-( |
gen_statem:send_request(ServerRef, Request, Label, Requests); |
| 43 |
|
|
| 44 |
|
send_request(#{requests := _} = Arg) -> |
| 45 |
:-( |
error(badarg, [Arg]); |
| 46 |
|
|
| 47 |
|
send_request(#{server_ref := ServerRef, request := Request}) -> |
| 48 |
176 |
gen_statem:send_request(ServerRef, Request). |
| 49 |
|
|
| 50 |
|
|
| 51 |
|
-spec nei(any()) -> {next_event, internal, any()}. |
| 52 |
|
|
| 53 |
|
nei(Event) -> |
| 54 |
5737 |
{next_event, internal, Event}. |