# Module ra_snapshot

- Data Types
- Function Index
- Function Details

## Data Types

### effect()

    effect() = {monitor, process, snapshot_writer, pid()}

### file_err()

    file_err() = file:posix() | badarg | terminated | system_limit

### meta()

    meta() = {ra_index(), ra_term(), ra_cluster_servers()}

### state()

abstract datatype: `state()`

## Function Index

init/3 |
init_ets/0 |
current/1 |
pending/1 |
accepting/1 |
directory/1 |
last_index_for/1 |
begin_snapshot/3 |
complete_snapshot/2 |
begin_accept/2 |
accept_chunk/4 |
abort_accept/1 |
handle_down/3 |
delete/2 |
save/4 |
begin_read/1 |
read_chunk/3 |
recover/1 |
read_meta/2 |

## Function Details

### init/3

    init(UId :: ra_uid(),
         Module :: module(),
         SnapshotsDir :: file:filename()) ->
            state()

### init_ets/0

    init_ets() -> ok

### current/1

    current(X1 :: state()) -> maybe(ra_idxterm())

### pending/1

    pending(X1 :: state()) -> maybe({pid(), ra_idxterm()})

### accepting/1

    accepting(X1 :: state()) -> maybe(ra_idxterm())

### directory/1

    directory(X1 :: state()) -> file:filename()

### last_index_for/1

    last_index_for(UId :: ra_uid()) -> maybe(ra_index())

### begin_snapshot/3

    begin_snapshot(Meta :: meta(),
                   ReleaseCursorRef :: term(),
                   State :: state()) ->
                      {state(), [effect()]}

### complete_snapshot/2

    complete_snapshot(IdxTerm :: ra_idxterm(), State :: state()) ->
                         state()

### begin_accept/2

    begin_accept(Meta :: meta(), State :: state()) -> {ok, state()}

### accept_chunk/4

    accept_chunk(Chunk :: term(),
                 Num :: non_neg_integer(),
                 ChunkFlag :: chunk_flag(),
                 State :: state()) ->
                    {ok, state()}

### abort_accept/1

    abort_accept(State :: state()) -> state()

### handle_down/3

    handle_down(Pid :: pid(), Info :: term(), State :: state()) ->
                   state()

### delete/2

`delete(Dir, X2) -> any()`

### save/4

    save(Module :: module(),
         Location :: file:filename(),
         Meta :: meta(),
         Data :: term()) ->
            ok | {error, file_err() | term()}

### begin_read/1

    begin_read(State :: state()) ->
                  {ok, Meta :: meta(), ReadState} | {error, term()}

-     ReadState = term()

### read_chunk/3

    read_chunk(ReadState,
               ChunkSizeBytes :: non_neg_integer(),
               State :: state()) ->
                  {ok, Data :: term(), {next, ReadState} | last} |
                  {error, term()}

-     ReadState = term()

### recover/1

    recover(X1 :: state()) ->
               {ok, Meta :: meta(), State :: term()} |
               {error, no_current_snapshot} |
               {error, term()}

### read_meta/2

    read_meta(Module :: module(), Location :: file:filename()) ->
                 {ok, meta()} |
                 {error,
                  invalid_format |
                  {invalid_version, integer()} |
                  checksum_error |
                  file_err() |
                  term()}

Generated by EDoc