Skip to content

Commit

Permalink
Add request.status.
Browse files Browse the repository at this point in the history
  • Loading branch information
smimram committed May 4, 2021
1 parent 4087020 commit 97cdbf6
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Expand Up @@ -82,6 +82,7 @@ New:
- Added `time.up`.
- Added `video.cover`.
- Added `video.still_frame`.
- Added `request.status`.

Changed:

Expand Down
16 changes: 16 additions & 0 deletions src/lang/builtins_request.ml
Expand Up @@ -179,3 +179,19 @@ let () =
[("", Lang.request_t, None, None)] Lang.int_t (fun p ->
let r = Lang.to_request (List.assoc "" p) in
Lang.int (Request.get_id r))

let () =
add_builtin "request.status" ~cat:Liq
~descr:
"Current status of a request. Can be idle, resolving, ready, playing or \
destroyed." [("", Lang.request_t, None, None)] Lang.string_t (fun p ->
let r = Lang.to_request (List.assoc "" p) in
let s =
match Request.status r with
| Request.Idle -> "idle"
| Request.Resolving -> "resolving"
| Request.Ready -> "ready"
| Request.Playing -> "playing"
| Request.Destroyed -> "destroyed"
in
Lang.string s)
5 changes: 3 additions & 2 deletions src/request.ml
Expand Up @@ -148,8 +148,9 @@ type t = {
mutable decoder : (unit -> Decoder.file_decoder_ops) option;
}

let ctype x = x.ctype
let initial_uri x = x.initial_uri
let ctype r = r.ctype
let initial_uri r = r.initial_uri
let status r = r.status

let indicator ?(metadata = Hashtbl.create 10) ?temporary s =
{ string = home_unrelate s; temporary = temporary = Some true; metadata }
Expand Down
6 changes: 6 additions & 0 deletions src/request.mli
Expand Up @@ -58,6 +58,12 @@ val initial_uri : t -> string
staticity, and in [src/sources/one_file.ml] for an example of use). *)
val destroy : ?force:bool -> t -> unit

(** Status of a request. *)
type status = Idle | Resolving | Ready | Playing | Destroyed

(** Current status of a request. *)
val status : t -> status

(** {1 General management} *)

(** Called at exit, for cleaning temporary files and destroying all the
Expand Down

0 comments on commit 97cdbf6

Please sign in to comment.