This is an automated email from the ASF dual-hosted git repository.

alamb pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git


The following commit(s) were added to refs/heads/main by this push:
     new 985ec7e28e Add `get_ref/get_mut` to JSON Writer (#7854)
985ec7e28e is described below

commit 985ec7e28ed481f5d6aa1e5a7ef9b93bd1050da9
Author: Peter L <[email protected]>
AuthorDate: Sat Jul 5 21:03:31 2025 +0930

    Add `get_ref/get_mut` to JSON Writer (#7854)
    
    # Which issue does this PR close?
    
    None
    
    # Rationale for this change
    
    I need access to the writer so that I can flush an external buffer when
    bytes are written.
    
    # What changes are included in this PR?
    
    A couple of methods to the JSON writer. These methods already exist on
    other writers
    
    # Are these changes tested?
    
    N/A
    
    # Are there any user-facing changes?
    
    Yes, a couple extra methods on the JSON writer.
    
    ---------
    
    Co-authored-by: Andrew Lamb <[email protected]>
---
 arrow-json/src/writer/mod.rs | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/arrow-json/src/writer/mod.rs b/arrow-json/src/writer/mod.rs
index 549fe77dfe..e2015692ca 100644
--- a/arrow-json/src/writer/mod.rs
+++ b/arrow-json/src/writer/mod.rs
@@ -413,6 +413,19 @@ where
         Ok(())
     }
 
+    /// Gets a reference to the underlying writer.
+    pub fn get_ref(&self) -> &W {
+        &self.writer
+    }
+
+    /// Gets a mutable reference to the underlying writer.
+    ///
+    /// Writing to the underlying writer must be done with care
+    /// to avoid corrupting the output JSON.
+    pub fn get_mut(&mut self) -> &mut W {
+        &mut self.writer
+    }
+
     /// Unwraps this `Writer<W>`, returning the underlying writer
     pub fn into_inner(self) -> W {
         self.writer

Reply via email to