Skip to content
Permalink
Browse files
[AVRO-3506] followup: Specific rename (#1682)
* renamed

* fmt
  • Loading branch information
jklamer committed May 8, 2022
1 parent ce74e77 commit ae89799545df2ffdb7cc8b42ce7ed63c435ed340
Showing 3 changed files with 11 additions and 10 deletions.
@@ -52,7 +52,7 @@ fn main() {
let file_message = std::fs::read(format!("{}/test_message.bin", RESOURCES_FOLDER))
.expect("File with single object not found or error occurred while reading");
let mut generated_encoding: Vec<u8> = Vec::new();
apache_avro::SingleObjectWriter::<InteropMessage>::with_capacity(1024)
apache_avro::SpecificSingleObjectWriter::<InteropMessage>::with_capacity(1024)
.expect("resolve expected")
.write_value(InteropMessage, &mut generated_encoding)
.expect("Should encode");
@@ -746,7 +746,7 @@ pub use reader::{from_avro_datum, Reader};
pub use schema::Schema;
pub use ser::to_value;
pub use util::max_allocation_bytes;
pub use writer::{to_avro_datum, GenericSingleObjectWriter, SingleObjectWriter, Writer};
pub use writer::{to_avro_datum, GenericSingleObjectWriter, SpecificSingleObjectWriter, Writer};

#[macro_use]
extern crate log;
@@ -408,28 +408,28 @@ impl GenericSingleObjectWriter {
}

/// Writer that encodes messages according to the single object encoding v1 spec
pub struct SingleObjectWriter<T>
pub struct SpecificSingleObjectWriter<T>
where
T: AvroSchema,
{
inner: GenericSingleObjectWriter,
_model: PhantomData<T>,
}

impl<T> SingleObjectWriter<T>
impl<T> SpecificSingleObjectWriter<T>
where
T: AvroSchema,
{
pub fn with_capacity(buffer_cap: usize) -> AvroResult<SingleObjectWriter<T>> {
pub fn with_capacity(buffer_cap: usize) -> AvroResult<SpecificSingleObjectWriter<T>> {
let schema = T::get_schema();
Ok(SingleObjectWriter {
Ok(SpecificSingleObjectWriter {
inner: GenericSingleObjectWriter::new_with_capacity(&schema, buffer_cap)?,
_model: PhantomData,
})
}
}

impl<T> SingleObjectWriter<T>
impl<T> SpecificSingleObjectWriter<T>
where
T: AvroSchema + Into<Value>,
{
@@ -441,7 +441,7 @@ where
}
}

impl<T> SingleObjectWriter<T>
impl<T> SpecificSingleObjectWriter<T>
where
T: AvroSchema + Serialize,
{
@@ -1177,8 +1177,9 @@ mod tests {
1024,
)
.expect("Should resolve schema");
let mut specific_writer = SingleObjectWriter::<TestSingleObjectWriter>::with_capacity(1024)
.expect("Resolved should pass");
let mut specific_writer =
SpecificSingleObjectWriter::<TestSingleObjectWriter>::with_capacity(1024)
.expect("Resolved should pass");
specific_writer
.write(obj1.clone(), &mut buf1)
.expect("Serialization expected");

0 comments on commit ae89799

Please sign in to comment.