Function vonuvoli_scheme::internals::builtins::port_input_coerce_arguments [−][src]
pub fn port_input_coerce_arguments<'a>(
port: &'a Value,
count: Option<&'a Value>,
full: Option<bool>,
full_default: bool
) -> Outcome<(&'a Port, Option<usize>, bool, usize)>
Arguments
count
defaults toDEFAULT_PORT_BUFFER_SIZE
if (the original)full
isNone
andfull_default
isfalse
;full
defaults toSome (true)
if (the original)count
isSome(_)
; else it defaults tofull_default
;- (
full_default
mainly is used by*_read_*_until
family of functions;)
Returns
&Port
count : Option<usize>
-- the actualcount
to be used by the above rules;full : bool
-- the actualfull
to be used by the above rules;buffer : usize
-- the "guessed" buffer capacity required;
Notes
Combining count
and full
one can obtain a wide range of behaviour:
count == Some (_)
andfull == Some (true) | None
-- read exactlycount
bytes; (could require multiple syscalls;)count == Some (_)
andfull == Some (false)
-- read at mostcount
bytes; (should require a single syscall;)count == None
andfull == Some (true)
-- read everything untilEOF
; (could require multiple syscalls;)count == None
andfull == Some (false) | None
-- read any bytes available; (should require a single syscall;)count == Some (0)
-- makes no sense!