11use super :: * ;
2- use crate :: chunk:: WriteSettings ;
2+ use crate :: chunk:: Settings ;
33use crate :: object:: { is_delimiter_character, TextStrLike } ;
44
55/// A builder for a content stream.
66pub struct Content {
77 buf : Buf ,
8- write_settings : WriteSettings ,
8+ settings : Settings ,
99 q_depth : usize ,
1010}
1111
@@ -19,9 +19,9 @@ impl Content {
1919 }
2020
2121 /// Create a new content stream with the given write settings.
22- pub fn with_settings ( write_settings : WriteSettings ) -> Self {
22+ pub fn with_settings ( settings : Settings ) -> Self {
2323 let mut content = Self :: new ( ) ;
24- content. write_settings = write_settings ;
24+ content. settings = settings ;
2525
2626 content
2727 }
@@ -31,14 +31,14 @@ impl Content {
3131 Self {
3232 buf : Buf :: with_capacity ( capacity) ,
3333 q_depth : 0 ,
34- write_settings : Default :: default ( ) ,
34+ settings : Default :: default ( ) ,
3535 }
3636 }
3737
3838 /// Start writing an arbitrary operation.
3939 #[ inline]
4040 pub fn op < ' a > ( & ' a mut self , operator : & ' a str ) -> Operation < ' a > {
41- Operation :: start ( & mut self . buf , operator, self . write_settings )
41+ Operation :: start ( & mut self . buf , operator, self . settings )
4242 }
4343
4444 /// Return the buffer of the content stream.
@@ -65,17 +65,13 @@ pub struct Operation<'a> {
6565 buf : & ' a mut Buf ,
6666 op : & ' a str ,
6767 first : bool ,
68- write_settings : WriteSettings ,
68+ settings : Settings ,
6969}
7070
7171impl < ' a > Operation < ' a > {
7272 #[ inline]
73- pub ( crate ) fn start (
74- buf : & ' a mut Buf ,
75- op : & ' a str ,
76- write_settings : WriteSettings ,
77- ) -> Self {
78- Self { buf, op, first : true , write_settings }
73+ pub ( crate ) fn start ( buf : & ' a mut Buf , op : & ' a str , settings : Settings ) -> Self {
74+ Self { buf, op, first : true , settings }
7975 }
8076
8177 /// Write a primitive operand.
@@ -108,7 +104,7 @@ impl<'a> Operation<'a> {
108104 // Similarly to how chunks are handled, we always add padding when pretty-writing
109105 // is enabled, and only lazily add padding depending on whether it's really necessary
110106 // if not.
111- let needs_padding = if self . write_settings . pretty {
107+ let needs_padding = if self . settings . pretty {
112108 if !self . buf . is_empty ( ) {
113109 self . buf . push ( pad_byte) ;
114110 }
@@ -119,7 +115,7 @@ impl<'a> Operation<'a> {
119115 } ;
120116
121117 self . first = false ;
122- Obj :: direct ( self . buf , 0 , self . write_settings , needs_padding)
118+ Obj :: direct ( self . buf , 0 , self . settings , needs_padding)
123119 }
124120}
125121
@@ -130,7 +126,7 @@ impl Drop for Operation<'_> {
130126
131127 // For example, in case we previously wrote a BT operator and then a [] operand in the
132128 // next operation, we don't need to pad them.
133- if ( self . write_settings . pretty
129+ if ( self . settings . pretty
134130 || self . buf . last ( ) . is_some_and ( |b| !is_delimiter_character ( * b) ) )
135131 && !self . buf . is_empty ( )
136132 {
@@ -1751,7 +1747,7 @@ mod tests {
17511747
17521748 #[ test]
17531749 fn test_content_array_no_pretty ( ) {
1754- let mut content = Content :: with_settings ( WriteSettings { pretty : false } ) ;
1750+ let mut content = Content :: with_settings ( Settings { pretty : false } ) ;
17551751
17561752 content. set_font ( Name ( b"F1" ) , 12.0 ) ;
17571753 content. set_font ( Name ( b"F2" ) , 15.0 ) ;
@@ -1775,7 +1771,7 @@ mod tests {
17751771
17761772 #[ test]
17771773 fn test_content_dict_no_pretty ( ) {
1778- let mut content = Content :: with_settings ( WriteSettings { pretty : false } ) ;
1774+ let mut content = Content :: with_settings ( Settings { pretty : false } ) ;
17791775
17801776 let mut mc = content. begin_marked_content_with_properties ( Name ( b"Test" ) ) ;
17811777 let mut properties = mc. properties ( ) ;
0 commit comments