chiark / gitweb /
multipart: process_boundary: Rename, and better docs
[hippotat.git] / src / multipart.rs
index b858039c73e782c6993442548e70bf08c9f9be99..b076458100315b3cf37469a0086b763043def6bd 100644 (file)
@@ -7,7 +7,7 @@ use crate::prelude::*;
 #[derive(Debug)]
 pub struct Component<'b> {
   pub name: PartName,
-  pub payload_start: &'b [u8],
+  pub payload: &'b [u8],
 }
 
 #[derive(Debug)]
@@ -18,9 +18,13 @@ pub enum PartName { m, d, Other }
 pub type BoundaryFinder = memchr::memmem::Finder<'static>;
 
 #[throws(AE)]
-pub fn process_component<'b>(warnings: &mut Warnings,
-                             after_leader: &'b [u8], expected: PartName)
-                             -> Option<Component<'b>> {
+/// Processes the start of a component (or terminating boundary).
+///
+/// Returned payload is only the start of the payload; the next
+/// boundary has not been identified.
+pub fn process_boundary<'b>(warnings: &mut Warnings,
+                            after_leader: &'b [u8], expected: PartName)
+                            -> Option<Component<'b>> {
   let rhs = after_leader;
   let mut rhs =
        if let Some(rhs) = rhs.strip_prefix(b"\r\n") { rhs         }
@@ -73,7 +77,7 @@ pub fn process_component<'b>(warnings: &mut Warnings,
     };
   }
 
-  Some(Component { name: part_name.unwrap_or(expected), payload_start: rhs })
+  Some(Component { name: part_name.unwrap_or(expected), payload: rhs })
 }
 
 pub struct MetadataFieldIterator<'b> {