pub struct AsdfBuilder { /* private fields */ }Expand description
Builds an ASDF file.
Implementations§
Source§impl AsdfBuilder
impl AsdfBuilder
Sourcepub fn with_compression(self, compression: Compression) -> Self
pub fn with_compression(self, compression: Compression) -> Self
Compress every array written from here on.
Blocks already in the builder – those an AsdfFile::edit brought
over – keep the compression they had. Use
AsdfBuilder::recompress to change those too.
Sourcepub fn recompress(self, compression: Compression) -> Self
pub fn recompress(self, compression: Compression) -> Self
Compress every block, including those already here.
This is how a whole file’s compression is changed: open it, edit it, recompress, write it back. Each block’s data is already decompressed in the builder, so this only decides how it goes out.
Sourcepub fn document_mut(&mut self) -> &mut Document
pub fn document_mut(&mut self) -> &mut Document
The tree being built, for direct manipulation.
Sourcepub fn set_str(&mut self, path: &str, value: &str) -> Result<()>
pub fn set_str(&mut self, path: &str, value: &str) -> Result<()>
Set a string. It is quoted where needed so it reads back as a string.
Sourcepub fn set_array<T: ArrayElement>(
&mut self,
path: &str,
values: &[T],
) -> Result<()>
pub fn set_array<T: ArrayElement>( &mut self, path: &str, values: &[T], ) -> Result<()>
Write a one-dimensional array of any scalar type.
let mut builder = asdf::AsdfBuilder::new();
builder.set_array("counts", &[1u16, 2, 3])?;
builder.set_array("ratios", &[0.5f32, 1.5])?;Sourcepub fn set_array_shaped<T: ArrayElement>(
&mut self,
path: &str,
values: &[T],
shape: &[u64],
) -> Result<()>
pub fn set_array_shaped<T: ArrayElement>( &mut self, path: &str, values: &[T], shape: &[u64], ) -> Result<()>
Write a multi-dimensional array of any scalar type.
The data is taken in C order, and its length must match the shape.
Sourcepub fn set_array_u64(&mut self, path: &str, values: &[u64]) -> Result<()>
pub fn set_array_u64(&mut self, path: &str, values: &[u64]) -> Result<()>
Write a one-dimensional u64 array. See AsdfBuilder::set_array.
Sourcepub fn set_array_i64(&mut self, path: &str, values: &[i64]) -> Result<()>
pub fn set_array_i64(&mut self, path: &str, values: &[i64]) -> Result<()>
Write a one-dimensional i64 array. See AsdfBuilder::set_array.
Sourcepub fn set_array_f64(&mut self, path: &str, values: &[f64]) -> Result<()>
pub fn set_array_f64(&mut self, path: &str, values: &[f64]) -> Result<()>
Write a one-dimensional f64 array. See AsdfBuilder::set_array.
Sourcepub fn set_array_f64_shaped(
&mut self,
path: &str,
values: &[f64],
shape: &[u64],
) -> Result<()>
pub fn set_array_f64_shaped( &mut self, path: &str, values: &[f64], shape: &[u64], ) -> Result<()>
Write a multi-dimensional f64 array.