Skip to main content

OutStream

Struct OutStream 

Source
pub struct OutStream<'a> { /* private fields */ }
Expand description

The stream request arguments are written to.

It dereferences to the CDR Encoder of the message body, and adds the operations that depend on the connection: string in the negotiated code set, wchar and wstring only when a wide code set was negotiated, and object references.

Implementations§

Source§

impl<'a> OutStream<'a>

Source

pub fn standalone(enc: &'a mut Encoder) -> OutStream<'a>

A stream over enc outside any message, with the native code sets (UTF-8 and UTF-16). Bindings use it to marshal the value of an any on its own, to read it back with InStream::standalone.

Source

pub fn code_sets(&self) -> CodeSets

The transmission code sets of the connection.

Source

pub fn set_code_sets(&mut self, code_sets: CodeSets)

Uses code_sets for the char and wchar data that follows, as on a standalone stream that must match another ORB’s native code sets.

Source

pub fn write_string(&mut self, s: &str) -> Result<(), SystemException>

Writes a string in the negotiated char code set.

Source

pub fn write_wchar(&mut self, c: u16) -> Result<(), SystemException>

Writes a wchar (one UTF-16 code unit).

Source

pub fn write_wstring(&mut self, s: &str) -> Result<(), SystemException>

Writes a wstring.

Source

pub fn write_object( &mut self, obj: Option<&ObjectRef>, ) -> Result<(), SystemException>

Writes an object reference; None is a nil reference.

Source

pub fn write_typecode(&mut self, tc: &TypeCode) -> Result<(), SystemException>

Writes a TypeCode. An unresolved recursive placeholder is BAD_TYPECODE.

Source

pub fn write_value( &mut self, tc: &TypeCode, v: &Value, ) -> Result<(), SystemException>

Writes a value of type tc. A value that does not fit the type is BAD_PARAM.

Source

pub fn write_fixed( &mut self, digits: &[u8], negative: bool, ) -> Result<(), SystemException>

Writes a fixed of digits.len() digits (each 0 to 9, most significant first) as packed decimal. A digit over 9 or more than 31 digits is BAD_PARAM.

Source

pub fn write_any(&mut self, any: &Any) -> Result<(), SystemException>

Writes an any: its TypeCode, then its value.

Methods from Deref<Target = Encoder>§

Source

pub fn set_wstring_bom(&mut self, bom: bool)

Chooses how a GIOP 1.2 wstring is written: with a BOM followed by code units in the stream byte order (the default, as omniORB does), or, when false, big endian without a BOM (the form the specification defines for a missing BOM). Readers that follow CORBA 2.4 or later accept both.

Source

pub fn byte_order(&self) -> ByteOrder

The byte order of the stream.

Source

pub fn encoding(&self) -> Encoding

The encoding whose rules apply.

Source

pub fn position(&self) -> usize

The stream offset of the next byte.

A caller that writes bytes depending on it (an offset or an indirection) calls pin as well.

Source

pub fn track_align8(&mut self)

Starts recording where the stream is aligned to 8 bytes, so that the bytes written from here on can be moved by 4 bytes with take_align8. Only for GIOP encodings; recording stops for good when something is written whose bytes depend on stream offsets: a valuetype, a call to pin, set_origin, as_bytes_mut or truncate.

Source

pub fn take_align8(&mut self) -> Option<Vec<(usize, usize)>>

Stops recording, and returns the 8-byte alignment points written since track_align8: each is the buffer length before its padding and the length of that padding. Data whose alignment is at most 4 does not depend on the stream offset modulo 8, so the bytes written since can be moved by 4 bytes by recomputing the padding at these points alone. None if not recording, or if recording stopped.

Source

pub fn pin(&mut self)

Says that bytes written from here on depend on stream offsets, as an indirection does, so the stream cannot be moved: stops track_align8 for good.

Source

pub fn len(&self) -> usize

Bytes written so far, shared octets included.

Source

pub fn is_empty(&self) -> bool

Whether nothing has been written.

Source

pub fn as_bytes(&self) -> &[u8] ⓘ

The bytes written into the buffer so far: all of them, unless shared octets were kept apart.

Source

pub fn as_bytes_mut(&mut self) -> &mut [u8] ⓘ

Mutable access to the buffer, for patching lengths. Indexes are buffer indexes, which differ from stream offsets after shared octets.

Source

pub fn truncate(&mut self, len: usize)

Drops bytes past len, which must not be before shared octets.

Source

pub fn reserve(&mut self, additional: usize)

Makes room for at least additional more bytes in the buffer.

Source

pub fn allow_shared(&mut self, allow: bool)

Lets write_octet_seq_shared keep large octet sequences apart from the buffer. Only for an encoder whose result goes out through into_parts or into_bytes, not one read through as_bytes.

Source

pub fn align(&mut self, align: usize)

Pads with zero octets until the stream offset is a multiple of align, or of the encoding’s max_align when that is smaller.

In an XCDR stream the offset counts from the alignment origin (see set_origin).

Source

pub fn origin(&self) -> usize

The stream offset alignment counts from: 0 unless changed with set_origin.

Source

pub fn set_origin(&mut self, origin: usize)

Makes alignment count from stream offset origin, which must not be past position. This is the XCDR PUSH(ORIGIN); the parameter headers of begin_parameter do it themselves.

Source

pub fn write_octet(&mut self, value: u8)

Writes an octet.

Source

pub fn write_bool(&mut self, value: bool)

Writes a boolean.

Source

pub fn write_char(&mut self, value: u8)

Writes a char as a single octet in the transmission code set.

Source

pub fn write_i16(&mut self, value: i16)

Writes a short.

Source

pub fn write_u16(&mut self, value: u16)

Writes an unsigned short.

Source

pub fn write_i32(&mut self, value: i32)

Writes a long.

Source

pub fn write_u32(&mut self, value: u32)

Writes an unsigned long.

Source

pub fn write_i64(&mut self, value: i64)

Writes a long long.

Source

pub fn write_u64(&mut self, value: u64)

Writes an unsigned long long.

Source

pub fn write_f32(&mut self, value: f32)

Writes a float.

Source

pub fn write_f64(&mut self, value: f64)

Writes a double.

Source

pub fn write_long_double(&mut self, value: LongDouble)

Writes a long double: 16 octets on an 8 octet boundary.

Source

pub fn write_octets(&mut self, bytes: &[u8])

Writes raw octets without alignment or a length.

Source

pub fn write_len(&mut self, len: usize) -> Result<(), Error>

Writes a sequence length.

Source

pub fn write_octet_seq(&mut self, bytes: &[u8]) -> Result<(), Error>

Writes a sequence<octet>.

Source

pub fn write_octet_seq_shared(&mut self, octets: &Octets) -> Result<(), Error>

Writes a sequence<octet> without copying a large one, if the encoder allows it and no valuetype is being written (whose chunk lengths count the buffer), and the encoding is a GIOP one (XCDR headers are patched in the buffer). Otherwise like write_octet_seq.

Source

pub fn write_string_bytes(&mut self, bytes: &[u8]) -> Result<(), Error>

Writes a string from bytes already in the transmission code set.

The length includes the terminating NUL, which is appended here.

Source

pub fn write_string(&mut self, value: &str) -> Result<(), Error>

Writes a string as UTF-8.

Source

pub fn write_wchar(&mut self, value: u16) -> Result<(), Error>

Writes a wchar holding one UTF-16 code unit.

GIOP 1.1 and XCDR (Char16, DDS-XTypes 7.4.1.1.1) write an aligned unsigned short in the stream byte order. GIOP 1.2 writes an octet length of 2 followed by the code unit in big endian without a BOM, as omniORB does.

Source

pub fn write_wstring(&mut self, value: &str) -> Result<(), Error>

Writes a wstring encoded as UTF-16.

GIOP 1.1 writes the number of code units including a terminating NUL, then aligned code units in the stream byte order. GIOP 1.2 writes the octet length, then the code units without a terminator: by default a BOM followed by the stream byte order, or big endian without a BOM (see Encoder::set_wstring_bom). An empty string is just a zero length. XCDR (DDS-XTypes 7.4.1.1.2) writes the length in octets, then the code units in the stream byte order, without a BOM or a terminator.

Source

pub fn write_encapsulation<F>(&mut self, f: F) -> Result<(), Error>
where F: FnOnce(&mut Encoder) -> Result<(), Error>,

Writes an encapsulation as a sequence<octet>.

f writes the contents into a fresh encoder whose alignment starts at the byte order octet. The encapsulation uses this stream’s byte order and version.

Source

pub fn write_null_value(&mut self)

Writes a null value.

Source

pub fn begin_value( &mut self, key: u64, ids: &[&str], chunked: bool, ) -> Result<bool, Error>

Starts writing a value.

key identifies the value: if a value with the same key was written before in this stream, an indirection to it is written and false is returned. Otherwise the value tag and ids (repository ids, most derived first; none leaves the type to the receiver) are written and true is returned: the caller writes the state and then calls Encoder::end_value.

A value nested in a chunked value is chunked as well.

Source

pub fn end_value(&mut self) -> Result<(), Error>

Ends the value started by the last Encoder::begin_value that returned true.

Source

pub fn begin_dheader(&mut self) -> DHeaderMark

Writes a DHEADER to be filled in by end_dheader with the length of what is written in between (DDS-XTypes 7.4.3.4.1).

Marks of begin_dheader, begin_member and begin_parameter must be ended innermost first.

Source

pub fn end_dheader(&mut self, mark: DHeaderMark) -> Result<(), Error>

Fills in the DHEADER of mark.

Source

pub fn begin_member( &mut self, id: u32, must_understand: bool, ) -> Result<MemberMark, Error>

Starts a member of an XCDR2 mutable type: an EMHEADER for member id, filled in by end_member with the length of what is written in between (DDS-XTypes 7.4.3.4.2, rule 22). Only for Encoding::Xcdr2.

Source

pub fn end_member(&mut self, mark: MemberMark) -> Result<(), Error>

Fills in the EMHEADER of mark. A member of 1, 2, 4 or 8 octets gets a length code of 0 to 3 and no NEXTINT; any other gets length code 4 and its length in NEXTINT. (Length codes 5 to 7, which share NEXTINT with the member, are read but not written.)

Source

pub fn begin_parameter( &mut self, id: u32, must_understand: bool, ) -> Result<ParameterMark, Error>

Starts a parameter of an XCDR1 parameter list, or the header of an XCDR1 optional member: a parameter header for member id, filled in by end_parameter with the length of what is written in between (DDS-XTypes 7.4.1.2, rules 24 and 25).

The header is a short one (16-bit ID and length) when id is at most MAX_SHORT_PID, and an extended one (PID_EXTENDED) otherwise or when the member turns out longer than 65535 octets. Alignment counts from the byte after the header until end_parameter. An absent optional member is a parameter with nothing written in it.

Source

pub fn end_parameter(&mut self, mark: ParameterMark) -> Result<(), Error>

Fills in the parameter header of mark and restores the alignment origin. The length is that of the member, without padding (DDS-XTypes 7.4.1.2).

Source

pub fn end_parameter_list(&mut self, end: ListEnd)

Ends an XCDR1 parameter list with end and a zero length (rule 23).

Trait Implementations§

Source§

impl<'a> Debug for OutStream<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Deref for OutStream<'_>

Source§

type Target = Encoder

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Encoder

Dereferences the value.
Source§

impl DerefMut for OutStream<'_>

Source§

fn deref_mut(&mut self) -> &mut Encoder

Mutably dereferences the value.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for OutStream<'a>

§

impl<'a> !UnwindSafe for OutStream<'a>

§

impl<'a> Forget for OutStream<'a>

§

impl<'a> Freeze for OutStream<'a>

§

impl<'a> Move for OutStream<'a>

§

impl<'a> Send for OutStream<'a>

§

impl<'a> Sync for OutStream<'a>

§

impl<'a> Unpin for OutStream<'a>

§

impl<'a> UnsafeUnpin for OutStream<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more