#mime/multipart
Xu 0.16.0 API
import: #mime/multipart
counts: 3 functions, 11 methods, 3 types, 0 constants, 0 method sets
multipart Reader/Writer. EOF is the error EOF.
struct Part
pub struct Part {
pub keys []string
pub vals []string
pub body string
}
Purpose
Structure encapsulating keys, vals, body.
Public fields
keys []string- field ([]string)
vals []string- field ([]string)
body string- body
struct Reader
pub struct Reader {
pub data string
pub boundary string
pub pos int
pub closed int
}
Purpose
Multipart Streaming reader and decoder.
Public fields
data string- data
boundary string- field (string)
pos int- field (int)
closed int- field (int)
struct Writer
pub struct Writer {
pub boundary string
pub buf string
pub started int
pub closed int
}
Purpose
Multipart Streaming writer and encoder.
Public fields
boundary string- field (string)
buf string- buffer
started int- field (int)
closed int- field (int)
(Part) form_name
pub fn (p Part) form_name() string
Purpose
Operation on Part: form name.
Parameters
p Part- The
Part instance used by this call (value receiver).
Returns
string — result string
(Part) file_name
pub fn (p Part) file_name() string
Purpose
Operation on Part: file name.
Parameters
p Part- The
Part instance used by this call (value receiver).
Returns
string — result string
(Part) body
pub fn (p Part) body() string
Purpose
Execute body on Part.
Parameters
p Part- The
Part instance used by this call (value receiver).
Returns
string — result string
new_reader
pub fn new_reader(body &string, boundary &string) Reader
Purpose
Construct reader.
Parameters
body &string- body (read-only borrow; caller keeps the original; type &string)
boundary &string- boundary (read-only borrow; caller keeps the original; type &string)
Returns
Reader — a value of this type
($&Reader) next_part
pub fn (r $&Reader) next_part() Part
Purpose
Operation on $&Reader: next part. Throws on failure; handle the error or propagate it to the caller.
Parameters
r $&Reader- The
Reader instance used by this call (exclusive borrow).
Returns
Part — a value of this type
new_writer
pub fn new_writer() Writer
Purpose
Construct writer.
Parameters
No arguments are required.
Returns
Writer — a value of this type
new_writer_with_boundary
pub fn new_writer_with_boundary(boundary &string) Writer
Purpose
Construct writer with boundary.
Parameters
boundary &string- boundary (read-only borrow; caller keeps the original; type &string)
Returns
Writer — a value of this type
(Writer) boundary
pub fn (w Writer) boundary() string
Purpose
Execute boundary on Writer.
Parameters
w Writer- The
Writer instance used by this call (value receiver).
Returns
string — result string
(Writer) form_data_content_type
pub fn (w Writer) form_data_content_type() string
Purpose
Operation on Writer: form data content type.
Parameters
w Writer- The
Writer instance used by this call (value receiver).
Returns
string — result string
($&Writer) write_field
pub fn (w $&Writer) write_field(name &string, value &string)
Purpose
Operation on $&Writer: write field.
Parameters
w $&Writer- The
Writer instance used by this call (exclusive borrow).
name &string- name (read-only borrow; caller keeps the original; type &string)
value &string- value (read-only borrow; caller keeps the original; type &string)
Returns
This call does not return a value.
($&Writer) write_file
pub fn (w $&Writer) write_file(name &string, filename &string, content_type &string, body &string)
Purpose
Operation on $&Writer: write file.
Parameters
w $&Writer- The
Writer instance used by this call (exclusive borrow).
name &string- name (read-only borrow; caller keeps the original; type &string)
filename &string- filename (read-only borrow; caller keeps the original; type &string)
content_type &string- content_type (read-only borrow; caller keeps the original; type &string)
body &string- body (read-only borrow; caller keeps the original; type &string)
Returns
This call does not return a value.
($&Writer) close
pub fn (w $&Writer) close()
Purpose
Operation on $&Writer: close the resource.
Parameters
w $&Writer- The
Writer instance used by this call (exclusive borrow).
Returns
This call does not return a value.
(&Writer) bytes
pub fn (w &Writer) bytes() string
Purpose
Operation on &Writer: return the buffered bytes.
Parameters
w &Writer- The
Writer instance used by this call (borrow).
Returns
string — result string