]> git.proxmox.com Git - ceph.git/blame - ceph/src/jaegertracing/thrift/lib/php/lib/Transport/TTransport.php
buildsys: switch source download to quincy
[ceph.git] / ceph / src / jaegertracing / thrift / lib / php / lib / Transport / TTransport.php
CommitLineData
f67539c2
TL
1<?php
2/*
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 * @package thrift.transport
21 */
22
23namespace Thrift\Transport;
24
25use Thrift\Exception\TTransportException;
26use Thrift\Factory\TStringFuncFactory;
27
28/**
29 * Base interface for a transport agent.
30 *
31 * @package thrift.transport
32 */
33abstract class TTransport
34{
35 /**
36 * Whether this transport is open.
37 *
38 * @return boolean true if open
39 */
40 abstract public function isOpen();
41
42 /**
43 * Open the transport for reading/writing
44 *
45 * @throws TTransportException if cannot open
46 */
47 abstract public function open();
48
49 /**
50 * Close the transport.
51 */
52 abstract public function close();
53
54 /**
55 * Read some data into the array.
56 *
57 * @param int $len How much to read
58 * @return string The data that has been read
59 * @throws TTransportException if cannot read any more data
60 */
61 abstract public function read($len);
62
63 /**
64 * Guarantees that the full amount of data is read.
65 *
66 * @return string The data, of exact length
67 * @throws TTransportException if cannot read data
68 */
69 public function readAll($len)
70 {
71 // return $this->read($len);
72
73 $data = '';
74 $got = 0;
75 while (($got = TStringFuncFactory::create()->strlen($data)) < $len) {
76 $data .= $this->read($len - $got);
77 }
78
79 return $data;
80 }
81
82 /**
83 * Writes the given data out.
84 *
85 * @param string $buf The data to write
86 * @throws TTransportException if writing fails
87 */
88 abstract public function write($buf);
89
90 /**
91 * Flushes any pending data out of a buffer
92 *
93 * @throws TTransportException if a writing error occurs
94 */
95 public function flush()
96 {
97 }
98}