On this page:
mebibytes->bytes
transfer
$transfer
$transfer:  scope
$transfer:  progress
$transfer:  budget
$transfer:  budget:  exceeded
$transfer:  budget:  rejected
$transfer:  timeout
8.12

32 Ports🔗ℹ

 (require denxi/port) package: denxi

denxi/port reprovides all bindings from racket/port, in addition to the bindings defined in this section.

procedure

(mebibytes->bytes mebibytes)  exact-nonnegative-integer?

  mebibytes : real?
Converts mebibytes to bytes, rounded up to the nearest exact integer.

procedure

(transfer bytes-source    
  bytes-sink    
  #:on-status on-status    
  #:max-size max-size    
  #:buffer-size buffer-size    
  #:transfer-name transfer-name    
  #:est-size est-size    
  #:timeout-ms timeout-ms)  void?
  bytes-source : input-port?
  bytes-sink : output-port?
  on-status : (-> $transfer? any)
  max-size : (or/c +inf.0 exact-positive-integer?)
  buffer-size : exact-positive-integer?
  transfer-name : non-empty-string?
  est-size : (or/c +inf.0 real?)
  timeout-ms : (>=/c 0)
Like copy-port, except bytes are copied from bytes-source to bytes-sink, with at most buffer-size bytes at a time.

transfer applies on-status repeatedly and synchronously with $transfer messages.

transfer reads no more than N bytes from bytes-source, and will wait no longer than timeout-ms for the next available byte.

The value of N is computed using est-size and max-size. max-size is the prescribed upper limit for total bytes to copy. est-size is an estimated for the number of bytes that bytes-source will actually produce (this is typically not decided by the user). If (> est-size max-size), then the transfer will not start. Otherwise N is bound to est-size to hold bytes-source accountable for the estimate.

If est-size and max-size are both +inf.0, then transfer will not terminate if bytes-source does not produce eof.

struct

(struct $transfer $message ()
    #:prefab)
A message pertaining to a transfer status.

struct

(struct $transfer:scope $transfer (name message)
    #:prefab)
  name : string?
  message : (and/c $transfer? (not/c $transfer:scope?))
Contains a $transfer message from a call to transfer where the transfer-name argument was bound to name.

struct

(struct $transfer:progress $transfer (bytes-read
    max-size
    timestamp)
    #:prefab)
  bytes-read : exact-nonnegative-integer?
  max-size : (or/c +inf.0 exact-positive-integer?)
  timestamp : exact-positive-integer?
Represents progress transferring bytes to a local source.

Unless max-size is +inf.0, (/ bytes-read max-size) approaches 1. You can use this along with the timestamp (in seconds) to reactively compute an estimated time to complete.

struct

(struct $transfer:budget $transfer ()
    #:prefab)
A message pertaining to a transfer space budget.

struct

(struct $transfer:budget:exceeded $message (size)
    #:prefab)
  size : exact-positive-integer?
A request to transfer bytes was halted because the transfer read overrun-size bytes more than allowed-max-size bytes.

See DENXI_FETCH_TOTAL_SIZE_MB and DENXI_FETCH_PKGDEF_SIZE_MB.

struct

(struct $transfer:budget:rejected $message (proposed-max-size
    allowed-max-size)
    #:prefab)
  proposed-max-size : (or/c +inf.0 exact-positive-integer?)
  allowed-max-size : exact-positive-integer?
A request to transfer bytes never started because the transfer estimated proposed-max-size bytes, which exceeds the user’s maximum of allowed-max-size.

See DENXI_FETCH_TOTAL_SIZE_MB and DENXI_FETCH_PKGDEF_SIZE_MB.

struct

(struct $transfer:timeout $message (bytes-read wait-time)
    #:prefab)
  bytes-read : exact-nonnegative-integer?
  wait-time : (>=/c 0)
A request to transfer bytes was halted after bytes-read bytes because no more bytes were available after wait-time milliseconds.

See DENXI_FETCH_TIMEOUT_MS.